我正在学习OOP Javascript,我想知道为什么我需要使用constructor.prototype功能.我不能把我需要的所有功能都放在construtor功能中,如下所示:
function Class(){
this.x = x;
this.y = y;
this.--- = ---;
}
Run Code Online (Sandbox Code Playgroud)
而不是:
function Class(){
this.x = x;
}
Class.prototype = {
constructor : Class,
y : y
}
Run Code Online (Sandbox Code Playgroud)