function A() { this.a = 'a'; } A.prototype.b = 'b'; var a = new A(); console.log(a.a); var b = {}; b.__proto__ = A.prototype; A.call(b); console.log(b.a); __proto__指向创建该对象的构造函数的原型对象 prototype指向构造函数的原型对象
–来自一个程序员的座右铭(有问题,请及时留言)
function A() { this.a = 'a'; } A.prototype.b = 'b'; var a = new A(); console.log(a.a); var b = {}; b.__proto__ = A.prototype; A.call(b); console.log(b.a); __proto__指向创建该对象的构造函数的原型对象 prototype指向构造函数的原型对象