如题,下面是一个继承函数(子类可继承父类的属性及方法),但是不懂工作原理,求解,求科普,求链接。
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;
千巷猫影
相关分类