继承

function a(){
    this.sex=[1,2,3]
}
function b(){
    a.call(this)
    this.say=function(){
        console.log(b.say)
    }
}
b.prototype=new a();
var c=new b();
var d=new b();
c.sex.push(4)
console.log(c.sex)   //[1,2,3,4]
console.log(d.sex)   //[1,2,3]
function a(){
    this.sex=[1,2,3]
}
function b(){
    this.say=function(){
        console.log(b.say)
    }
}
b.prototype=new a();
var c=new b();
var d=new b();
c.sex.push(4)
console.log(c.sex)  //[1,2,3,4]
console.log(d.sex) //[1,2,3,4]
原文地址:https://www.cnblogs.com/wwx875075608/p/9227825.html