This tool function does not make sense, just because the extend method of ext is not well understood, wrote a simplified extend method to help understand.
/** * */e = {}; E.extend = function (Sub, SUP) {//Borrow constructor Sub.prototype = sup;//Preserve the constructor of the parent class in order to use the call in the subclass constructor, Bind the parent class variable under this sub.prototype.superclass = sup.constructor;//because the constructor is overridden so that constructor is re-specified, So that instanceof behaves normally sub.prototype.constructor = sub;//because the variable is bound to a subclass, delete the overridden variable for (var i-in sup) {if (typeof Sup[i]!== ' F on the prototype) Unction ') {delete sup[i];}} return sub;}; E.interfacefactory = {}; E.interfacefactory.createinterface = function (methods) {var Interface = function () {};var F = typeof arguments[0] = = = ' str ing '; var p = f? Arguments:arguments[0];var len = P.length;var _proto = Interface.prototype = {};for (var i = 0; i < len; i++) {_proto . p[i] = function () {throw new Error (' no implements function ');};} return new Interface ();};
Test
var person = function (name) {this.name = name;} Person.prototype.say = function () {alert (' I am ' + this.name);} var SS = function (name, age) {This.superclass.call (this,name); this.age = age;} SS = E.extend (ss, New Person (' sz ')), var s = new SS (' xx ', one-to-one); S.say ();