Javascript quiz
Link: http://perfectionkills.com/javascript-quiz/
You've got 4 answers wrong (#1, #3, #5, #14).
Very good, but not quite there yet.
错了4道题, GG,
1.
(function(){
return typeof arguments;
})();
这里 arguments 应该是一个参数的对象, 不是数组, 且次对象的值和参数值绑定, 例如
(function b(a) {
arguments[0] = 2;
return a;
})(1)
输出 2
3.
(function(x){
delete x;
return x;
})(1);
这里 delete x; 返回false(delete对参数不起作用), 所以x仍是1
Reference/Operators/delete
5.
(function f(f){
return typeof f();
})(function(){ return 1; });
参数覆盖了f的值, 所以f是参数的函数, 而不是函数本身
14.
with (function(x, undefined){}) length;
length应该是2
(function(){ console.log(arguments.length) })(1,null);
输出 2
(function(){ console.log(arguments.length) })(1,undefined);
输出 2