
function User(name){ this.name=name; } //对应左边的 // 此方法是挂上show // User.prototype.show=function(){ // console.log(this.name); // } //对应右边的 //此方法是是重新创建了一个property,所以需要加上constructor User.prototype={ constructor:User, show(){ console.log(this.name); } } let lisi =new User.prototype.constructor("lisi"); lisi.show();
浙公网安备 33010602011771号