JavaScriptを使って単純な古典的な継承を作りたいです。サブクラス化とメソッドのオーバーライドが必要なだけで、prototype.jsや他のライブラリによって提供されるような冗長な構文やベルやホイッスルは必要ありません。
さて、Shelby S. Mooreという名前のこの仲間は、私が望むように機能するソリューションを考え出しました:http: //www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html
唯一の問題は、彼がネイティブタイプのオブジェクトと関数を拡張していることです。これにより、私が使用しているライブラリの一部が壊れます。また、一般的な観察として、ネイティブオブジェクトのプロトタイプをいじりたくありません。
シェルビーS.ムーアの例をここに公開しました:http: //jsfiddle.net/christian1974/CEKL5/
例からわかるように、期待どおりに機能します。さて、64.000ドルの質問は次のとおりです。Object.prototypeとFunction.prototypeをいじらずに機能させる方法をお勧めしますか?
私は次のような本当に単純な構文を探していました:
Extend(parent, this);
アイデア全体を捨てて、これを行う既存のライブラリを使用する必要がありますか?私は自分の人生を難しくしすぎていませんか?