在 Chrome 中,
(function(){}).__proto__
是
function Empty() {}
所以我会期待
new Function();
是function Empty() {}, 但 是function anonymous() {}.
我在哪里可以找到function Empty() {}?是在里面Function还是在Object某个地方?
在 Chrome 中,
(function(){}).__proto__
是
function Empty() {}
所以我会期待
new Function();
是function Empty() {}, 但 是function anonymous() {}.
我在哪里可以找到function Empty() {}?是在里面Function还是在Object某个地方?
一个空函数对象(其名称为Empty)是Function.
Function.prototype.toString() === "function Empty() {}"
Object.getPrototypeOf(new Function()).toString() === "function Empty() {}"
这些名称并不意味着您可以使用这些标识符访问它们。
至于函数的原型,名称是在启动时设置的。该函数已被命名,但除了公开它之外.name,它并没有真正起到任何作用。.toString()
例如new Function(),名称仅打印为.toString(). .name空字符串也是如此。再一次,它没有多大用处。
Empty 是函数原型的名称。从 Chrome 控制台:
dir(Function)
function Function() { [native code] }
arguments: null
caller: null
length: 1
name: "Function"
prototype: function Empty() {}
__proto__: function Empty() {}
apply: function apply() { [native code] }
arguments: null
bind: function bind() { [native code] }
call: function call() { [native code] }
caller: null
constructor: function Function() { [native code] }
length: 0
name: "Empty"
toString: function toString() { [native code] }
__proto__: Object