prototype chain - javascript
作者:
Zihowe | 来源:发表于
2017-10-07 07:16 被阅读14次
![](https://img.haomeiwen.com/i3198327/0536bdf1409cb8f4.png)
image.png
function Person(firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
Person.prototype.greet = function() {
console.log('Hello, ' + this.firstname + ' ' + this.lastname);
};
var john = new Person('John', 'Doe');
john.greet();
var jane = new Person('Jane', 'Doe');
jane.greet();
console.log(john.__proto__);
console.log(jane.__proto__);
console.log(john.__proto__ === jane.__proto__);
本文标题:prototype chain - javascript
本文链接:https://www.haomeiwen.com/subject/womdyxtx.html
网友评论