1.2.4.2.瞭解原型
obj.prop1 obj.prop2 obj.prop3
var person = {
firstname: 'Default',
lastname: 'Default',
getFullName: function(){
return this.firstname + ' ' + this.lastname;
}
}
var john = {
firstname: 'John',
lastname: 'Doe'
}
//don't do this
john.__proto__ = person;
//印出'John Doe'
console.log(john.getFullName());
//印出'John'
console.log(john.firstname);Last updated
