クラスBがクラスAからすべてを継承する(クラスBがAを拡張する)ようにJavaScriptクラスを拡張する正しい/最良の方法は何ですか?
110011 次
3 に答える
57
Take a look at Simple JavaScript Inheritance and Inheritance Patterns in JavaScript.
The simplest method is probably functional inheritance but there are pros and cons.
于 2010-02-13T00:57:56.400 に答える
30
Douglas Crockford has some very good explanations of inheritance in JavaScript:
- prototypal inheritance: the 'natural' way to do things in JavaScript
- classical inheritance: closer to what you find in most OO languages, but kind of runs against the grain of JavaScript
于 2010-02-13T01:09:53.457 に答える
1
extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
};
for ループにフィルターを追加することもできます。
于 2012-10-28T15:28:31.170 に答える