函数与函数的关系

relationship between function and Function

我真的很想知道函数和函数之间的关系..

我读了那篇文章"function inherit the methods of Function",所以函数可以使用应用、绑定、调用等方法

所以我使用下面的代码检查了控制台。

function test(){} // statement
test.__proto__ // function(){[native code]}

啊..如果"function inherit the methods of Function"是真的,
为什么结果是 function(){[native code]},而不是函数 Function(){[native code]}?

我还检查了函数测试的构造函数是函数Function, 甚至让我感到困惑..

太奇怪了..需要一些帮助..

function test() {}new Function()都一样,控制台输出的是function ...而不是Function ...,所以还是一致的。他们这样做是有历史原因的,它反映了更多你通常在源代码中看到的东西。

console.log(new Function() );
console.log(function test(){} );

a.__proto__为原型

a.__proto__.constructorFunction

function a() { }
console.log(a.__proto__);
console.log(a.__proto__ === Function);

console.log(a.__proto__.constructor);
console.log(a.__proto__.constructor === Function);

a.__proto__ 几乎是一个用于初始化的匿名函数。

test 是使用构造函数 Function 创建的,test__proto__.constructor 将 return

test 的原型是 function () { [native code] } 从哪里继承(什么 test.__proto__),这就是为什么你能够访问 test.<some property name> 实际上是 属性 的 function () { [native code] }