构造函数的原型对象上定义一个对象

function a(){
this.sex=[1,2,3]
}
a.prototype={
age:[1,2,3],
say:function(){

}
}
var b=new a();
b.age.push(4)
console.log(a.prototype)
console.log(b.age)
var c=new a();
console.log(a.prototype)
console.log(c.age)

猜你喜欢

转载自www.cnblogs.com/wwx875075608/p/9222749.html