2
コードを記述するのが妥当です。関数のプロトタイプ自体をコンストラクタにする
function Base() {}
Base.prototype = function() {
// I am a constructor
}
const baseInstance = new Base()
const secondInstance = new baseInstance() // baseInstance is not a constructor
私は、コンストラクタに.prototype
の名前のプロパティを作ったが、私は自分のコードで上記のパターンを行うことができるようにしたい場合は、それは非常にシンプルになります理解しています。出来ますか?