>>> function () {}
SyntaxError
>>> f = function() {}
f = function() {}
>>> new function() {}
>>> Object
>>> new Function()
function anonymous() {}
>>> Function()
function anonymous() {}
>>> f = (function() { a = 10; return function() {console.log(a);} })();
>>> f()
10
undefined
>>> f = (function() { a = 10; return new Function('console.log(a)'); })();
>>> f()
undefined
因此,我有两个问题:
为什么
Function
即使没有运算符,构造函数也会返回一个新函数new
?用构造函数创建的
Function
函数不是闭包吗?