0
匿名函数当运行这个片段参数在严格模式
"use strict";
(new function test(a) { console.log(a); })(window);
为什么我得到undefined
为a
?为什么窗口没有传递给匿名函数?
匿名函数当运行这个片段参数在严格模式
"use strict";
(new function test(a) { console.log(a); })(window);
为什么我得到undefined
为a
?为什么窗口没有传递给匿名函数?
你在做什么(几乎)等价于:
"use strict";
function test(a) {
console.log(a);
}
val t = new test(undefined);
t(window);
只需卸下new
关键字:
"use strict";
(function test(a) { console.log(a); })(window);
'新功能...'返回一个对象,而不是一个函数 –