var a = 1;
function b() {
a = 10;
return;
function a() {}
}
b();
alert(a);
Run Code Online (Sandbox Code Playgroud)
如何显示1的输出?什么是
return;
function a() {}
Run Code Online (Sandbox Code Playgroud)
在功能体内执行?
var foo = {
bar: function() { return this.baz; },
baz: 1
};
(function(){
return typeof arguments[0]();
})(foo.bar);
Run Code Online (Sandbox Code Playgroud)
为什么这段代码会返回undefined?
我认为arguments[0]会持有foo.bar,这是一个功能.通过arguments[0]()它调用时,应该返回函数求值的结果,在这种情况下1.因此,typeof arguments[0]()应该返回"数字"(如typeof 1).相反,它返回undefined.为什么?
javascript ×2