当前位置: 代码迷 >> JavaScript >> javascript的承袭
  详细解决方案

javascript的承袭

热度:107   发布时间:2012-10-16 09:57:37.0
javascript的继承
来自 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;
};
  相关解决方案