为什么Javascript中的extend()方法不';不适用于3个或更多对象?

为什么Javascript中的extend()方法不';不适用于3个或更多对象?,javascript,oop,extend,javascript-objects,Javascript,Oop,Extend,Javascript Objects,我有三个目标 netBuilder 编号 NumberingMethodDefault console.log(NumberingMethodDefault.superclass); //and it was netBuilder, not Numbering! о_О 我有一些扩展方法 extend: function (Child, Parent) { var F = function () {}; F.prototype = Parent.prototype; Child.p

我有三个目标

netBuilder 编号 NumberingMethodDefault

console.log(NumberingMethodDefault.superclass);
//and it was netBuilder, not Numbering! о_О
我有一些扩展方法

extend: function (Child, Parent) {
  var F = function () {};
  F.prototype = Parent.prototype;
  Child.prototype = new F();
  Child.prototype.constructor = Child;
  Child.superclass = Parent.prototype;
  this.mixin(Child, Parent);
},
/**

 * @param {type} dst
 * @param {type} src
 * @returns {undefined}
 */
mixin: function (dst, src) {
  var tobj = {};
  for (var x in src) {
    if ((typeof tobj[x] == "undefined") || (tobj[x] != src[x])) {
      dst[x] = src[x];
    }
  }
  if (document.all && !document.isOpera) {
    var p = src.toString;
    if (typeof p == "function" && p != dst.toString && p != tobj.toString &&
      p != "\nfunction toString() {\n    [native code]\n}\n") {
      dst.toString = src.toString;
    }
  }
}
然后我尝试从netBuilder扩展编号,从编号扩展NumberingMethodDefault

oopUtility.extend(Numbering, netBuilder);
oopUtility.extend(NumberingMethodDefault, Numbering);
并调用超类

Numbering.superclass.constructor.call(this, arguments);
NumberingMethodDefault.superclass.constructor.call(this, arguments);
编号具有方法setNumber()。 我可以访问netBuilder方法的编号,但在NumberingMethodDefault中,我无法通过编号执行方法setNumber()

Uncaught TypeError: Object #<NumberingMethodDefault> has no method 'setNumber'

我怎样才能使它工作。我需要扩展3个或更多对象

这是因为对
mixin
的调用手动将属性从一个对象复制到另一个对象,并且正在覆盖
.superclass
赋值。如果你在模拟类继承,你就不需要以这种方式混合,所以完全删除那些代码,你就不会有问题。

如果((typeof tobj[x]=“undefined”)|(tobj[x]!=src[x])| tobj[x]!=超类),我可能需要一些If更改是的,这是工作<代码>如果((tobj[x]=“未定义”)| |(tobj[x]!=src[x])和&(src[x]!=src.superclass)){dst[x]=src[x];}