私は JavaScript が初めてで、パラメーターを受け取るコンストラクターがある場合に継承について頭を悩ませようとしています。
と呼ばれるベースオブジェクトがあるとしますBase
:
function Base(param1, param2) {
// Constructor for Base that does something with params
}
たとえばBaseChild
、 Base から継承するという別のオブジェクトと、から継承するChild
という別のオブジェクトが必要ですBaseChild
。
基本的な JavaScriptBaseChild
のコンストラクターを作成してChild
使用するにはどうすればよいでしょうか(つまり、特別なプラグインを使用しません)。
ノート:
次のように BaseChild を作成できると思いました。
var BaseChild = new Base(param1, param2);
param1
しかし、私はまたはparam2
の値を持っていませBaseChild
んChild
。これが理にかなっていることを願っています!.