我刚刚写了这段代码。
第一和第二个表达式返回true,但第三个表达式返回false。我不确定为什么它返回false,因为根据下面的图片,它应该返回true。
在这张图片中,您可以注意到Function.prototype的__proto__属性指向Object.prototype。
请问是否有人能够帮我澄清这些概念?
function Point(x,y){
this.x = x;
this.y = y;
}
var myPoint = new Point(4,5);
console.log(myPoint.__proto__ === Point.prototype);
console.log(Point.__proto__ === Function.prototype);
console.log(Function.__proto__ === Object.prototype);
第一和第二个表达式返回true,但第三个表达式返回false。我不确定为什么它返回false,因为根据下面的图片,它应该返回true。
![Inheritance](https://istack.dev59.com/LpMdV.webp)
请问是否有人能够帮我澄清这些概念?
Function
的原型实际上是Empty
函数。 - LJᛃnew Point()
和new Object()
一样调用new Function()
。 - hugomg