理解prototype—原型链
eg:
//类 构造函数
function Person(name){
this.name = name;
}
//实例化
var p1 = new Person3();
//创建原型对象
Person3.prototype.age = "23";
Person3.prototype.say = function(){
alert(this.name+":"+this.age)
}
p1.say();
![](https://images2015.cnblogs.com/blog/1076533/201703/1076533-20170302142307110-1423219842.png)
![](https://images2015.cnblogs.com/blog/1076533/201703/1076533-20170302142440641-1942525577.png)
eg:
//类 构造函数
function Person(name){
this.name = name;
}
//实例化
var p1 = new Person3();
//创建原型对象
Person3.prototype.age = "23";
Person3.prototype.say = function(){
alert(this.name+":"+this.age)
}
p1.say();
![](https://images2015.cnblogs.com/blog/1076533/201703/1076533-20170302142307110-1423219842.png)
![](https://images2015.cnblogs.com/blog/1076533/201703/1076533-20170302142440641-1942525577.png)