如題,下面是一個繼承函數(shù)(子類可繼承父類的屬性及方法),但是不懂工作原理,求解,求科普,求鏈接。var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key];
} function ctor() { this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
child.__super__ = parent.prototype; return child;
},
hasProp = {}.hasOwnProperty;
有人給我解釋下這個繼承函數(shù)是如何工作的么?
慕哥9229398
2018-08-06 10:09:16