function dad(){ this.name = "123" this.age = 33 } var dad1 = new dad() var dad2 = new dad() dad.prototype.funcd= ()=>{ console.log("funcdddddd") } //通過“dad.prototype.funName”添加方法,並影響所有的實例,eg:dad1, dad2 // dad1.prototype.funce= ()=>{ // console.log("funceeeee") // }// 不能通過"實例對象.prototype.funName"添加方法 dad1.funcf= ()=>{ console.log("funcffff") }// 不能通過"實例對象.prototype.funName"添加方法 dad1.funcd() dad2.funcd() dad1.funcf() // dad2.funcf() //只有dad1有這個方法
