来自 CasualJS,参考JavaScript高级程序设计(第2版)
//===================================================
//===================================================
/**
* Inheritance implementation for Javascript.
*/
var inherit = function(childClass, parentClass)
{
var tmpConstructor = function() {};
tmpConstructor.prototype = parentClass.prototype;
childClass.superClass = parentClass.prototype;
childClass.prototype = new tmpConstructor();
childClass.prototype.constructor = childClass;
return childClass;
};
本文介绍了一种在JavaScript中实现继承的方法,通过临时构造函数和原型链实现了子类对父类属性和方法的继承。
4660

被折叠的 条评论
为什么被折叠?



