首页 > 其他 > 详细

prototype 和 __proto__

时间:2021-05-29 17:48:08      阅读:20      评论:0      收藏:0      [点我收藏+]

function Person(name,age){

  this.name = name;

  this.age = age;

}

var person1 = new Person(‘jay‘,24);

console.log(person1.prototype); //undefined

console.log(person1.__proto__ === Person.prototype); //true

console.log(Person.__proto__ === Function.prototype);//true

console.log(Function.prototype.__proto__ === Object.prototype);//true

console.log(Object.prototype.__proto__);//null

 

总结:

1.prototype是构造函数的属性

2.__proto__是对象的属性

3.函数也是对象,所以也有__proto__属性  为函数的构造函数Function的原型对象

4.对象的prototype为undefined

prototype 和 __proto__

原文:https://www.cnblogs.com/jayking1314/p/14825255.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!