我已经看到人们做了很多次编码的方式,但是我通常不这样做,没有它我就可以正常工作,我只是好奇它是否重要.
注意:我标记了我所说的线条// this line
function Test(name, something){
this.name = name;
this.something = something
}
Test.prototype.name = ''; // this line
Test.prototype.something = ''; // this line
Test.prototype.getName = function(){
return this.name;
}
Run Code Online (Sandbox Code Playgroud) javascript ×1