關係:
1、每個構造函數都有一個原型屬性prototype,它指向原型對象
2、原型對象都包含一個指向構造函數的指針(constructor)
3、而實例都包含一個指向原型對象的內置指針(__ proto__)
代碼:
function Person(){ } //構造函數
Person.prototype.name = "bree"; //在構造函數的原型對象上添加屬性
Person.prototype.isName = function(){
alert(this.name)
}
var bree = new Person(); //調用構造函數創建的實例bree
console.log(bree.__proto__ === Person.prototype); //true
console.log(Person.prototype.constructor === Person); //true