日期:2014-05-16 浏览次数:20487 次
在阅读精通JavaScript(图灵计算机科学丛书)里面有讲解javascript继承的一些东东。
其一是讲解DouglasCrockford的js
代码如下:
第二个工具函数是base库
代码:
/* Base.js, version 1.1a Copyright 2006-2010, Dean Edwards License: http://www.opensource.org/licenses/mit-license.php */ var Base = function() { // dummy }; Base.extend = function(_instance, _static) { // subclass var extend = Base.prototype.extend; // build the prototype Base._prototyping = true; var proto = new this; extend.call(proto, _instance); proto.base = function() { // call this method from any other method to invoke that method's ancestor }; delete Base._prototyping; // create the wrapper for the constructor function //var constructor = proto.constructor.valueOf(); //-de