总结

xiaoxiao2021-02-28  83

1. ('test') instanceof String

会输出 false

2. 实现 add(2, 3); add(2)(3); 输出正确的结果:

function add(a, b) { if (arguments.length === 2) { return a + b; } else { return function (c) { return a + c; } } }

3.原生js实现删除点击的元素:

var div = document.getElementById('div') function removeElement(ele) { var _parent = ele.parentElement if (_parent) { _parent.removeChild(ele) } }

4. :checked 能匹配什么元素

匹配被选中的input元素(单选和复选框)

5. 下面alert和css加载的关系

<!doctype html> <html> <head> <link rel='stylesheet' href='/test.css'> </head> <body> <script> alert('hello') </script> </body> </html>

这个先会弹出hello,点击确定之后才会加载完css.

6. 结果是什么?

function test1(a, b) { arguments[1] = 2; console.log(b) } test1(1) // 输出undefined --------------------- function test2(a, b) { arguments[0] = 2 console.log(a) } test2(1) // 输出 2

arguments 的个数不是形参的个数,而是调用时传入的参数的个数。 并且可以改变参数值。

7. 多行居中

<div class='wrap'> <div class='item'></div> <div class='item'></div> <div class='item'></div> <div class='item'></div> <div class='item'></div> <div class='item'></div> <div class='item'></div> <div class='item'></div> </div> .wrap { display: table-cell; width: 500px; height: 500px; vertical-align: middle; text-align: center; } .item { display: inline-block; width: 100px; height: 100px; }

面试的题目其实很多都见过,但是平时不太注意,到那时候就忘了很多。

转载请注明原文地址: https://www.6miu.com/read-78370.html

最新回复(0)