1. [代码]Simple JavaScript Inheritance     
(function(){
  var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;

// The base Class implementation (does nothing)
  this.Class = function(){};
 
  // Create a new Class that inherits from this class
  Class.extend = function(prop) {
    var _super = this.prototype;
   
    // Instantiate a base class (but only create the instance,
    // don't run the init constructor)
    initializing = true;
    var prototype = new this();
    initializing = false;
   
    // Copy the properties over onto the new prototype
    for (var name in prop) {
      // Check if we're overwriting an existing function
      prototype[name] = typeof prop[name] == "function" &&
        typeof _super[name] == "function" && fnTest.test(prop[name]) ?
        (function(name, fn){http://www.huiyi8.com/jiaoben/​
          return function() {网页特效代码
            var tmp = this._super;
           
            // Add a new ._super() method that is the same method
            // but on the super-class
            this._super = _super[name];
           
            // The method only need to be bound temporarily, so we
            // remove it when we're done executing
            var ret = fn.apply(this, arguments);       
            this._super = tmp;
           
            return ret;
          };
        })(name, prop[name]) :
        prop[name];
    }
   
    // The dummy class constructor
    function Class() {
      // All construction is actually done in the init method
      if ( !initializing && this.init )
        this.init.apply(this, arguments);
    }
   
    // Populate our constructed prototype object
    Class.prototype = prototype;
   
    // Enforce the constructor to be what we expect
    Class.prototype.constructor = Class;

// And make this class extendable
    Class.extend = arguments.callee;
   
    return Class;
  };
})();

Simple JavaScript Inheritance的更多相关文章

  1. Join Resig's “Simple JavaScript Inheritance ”

    ======================Enein翻译=========================           John Resig 写了一篇关于 JavaScript 里类似其它语 ...

  2. Simple JavaScript Inheritance(John Resig)

    I’ve been doing a lot of work, lately, with JavaScript inheritance – namely for my work-in-progress ...

  3. Simple JavaScript Inheritance--一个极简JS面向对象-类库

    面向对象 面向对象思想的几个重要特征(针对类的要求): 抽象-封装.信息隐藏(将内部实现的方法和数据隐藏, 定义开放的接口) 继承-子类可以使用父类的资源,并可以定制自己的资源, 资源包括方法和数据 ...

  4. JavaScript Inheritance All in One

    JavaScript Inheritance All in One constructor inheritance prototype chain inheritance "use stri ...

  5. 大型 JavaScript 应用架构中的模式

    原文:Patterns For Large-Scale JavaScript Application Architecture by @Addy Osmani 今天我们要讨论大型 JavaScript ...

  6. 再读<<基于MVC的JavaScript Web 富应用开发>>

    工作的时候粗读过这本书的几章内容,真真是囫囵吞枣~~目前手边就剩这一本,重新读才觉得先前是没看明白啊!这个作者博闻强识,对这些插件.库了解的非常多.记录下,查的资料 订阅/发布 jQuery Tiny ...

  7. 全面理解面向对象的 JavaScript (share)

     以下分享自:  http://www.ibm.com/developerworks/cn/web/1304_zengyz_jsoo/   简介: JavaScript 函数式脚本语言特性以及其看似随 ...

  8. [转]大型 JavaScript 应用架构中的模式

    目录 1.我是谁,以及我为什么写这个主题 2.可以用140个字概述这篇文章吗? 3.究竟什么是“大型”JavaScript应用程序? 4.让我们回顾一下当前的架构 5.想得长远一些 6.头脑风暴 7. ...

  9. JavaScript强化教程——Cocos2d-JS中JavaScript继承

    javaScript语言本身没有提供类,没有其它语言的类继承机制,它的继承是通过对象的原型实现的,但这不能满足Cocos2d-JS引擎的要求.由于Cocos2d-JS引擎是从Cocos2d-x演变而来 ...

随机推荐

  1. [UIScreen mainScreen].applicationFrame与[UIScreen mainScreen].bounds区别

    [UIScreen mainScreen].applicationFrame与[UIScreen mainScreen].bounds区别: applicationFrame会自动判断是否存在状态栏, ...

  2. PHP验证码显示不出来

    PHP验证码显示不出来 验证码图片显示不出来,原因一般有三种(网上基本一致这几种原因): (1)php没有安装gd2模块,可以使用phpinfo()函数查看. (2)代码很可能是使用了像editpul ...

  3. mongo安装-docker

    拉取官方镜像(可以自己使用dockerFile构建): docker search mongo //查询Docker Hub 上的mongo镜像 docker pull mongo // 拉取官方镜像 ...

  4. 动态AdvStringGrid完美示例 (AdvStringGrid使用技巧/Cells)

    http://www.cnblogs.com/JackSun/archive/2010/12/16/1908104.html 此窗体,只需要简单准备如下,即可运行:    1,添加一个TAdvStri ...

  5. codeforces Gym 101572 I 有向图最小环路径

    题目链接 http://codeforces.com/gym/101572 题意  一共n个文件  存在依赖关系 根据给出的依赖关系   判断是否存在循环依赖 ,不存在的话输出SHIP IT,存在的话 ...

  6. BZOJ——1610: [Usaco2008 Feb]Line连线游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=1610 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 2 ...

  7. 【JSON注解】注解@JsonIgnoreProperties和@JsonIgnore的另一个使用情况

    之前关于这两个注解,是用在JSON循环引用的情况上,那么现在关于这两个注解,还可以使用在另外一种情况上 即: 一般标记在属性或者方法上,返回的json数据即不包含该属性 关于这种情况在什么时候会遇到呢 ...

  8. 【kotlin】基本语法when的使用,类似于java中的switch,但是又青出于蓝而胜于蓝

    when(要判断的参数){ 参数值为1 ->做这种事情 参数值为2 ->做另一种事情 else -> 类似于switch中的default } 扩展使用:https://www.cn ...

  9. Python基础语法07--面向对象+正则表达式

    Python 面向对象 Python从设计之初就已经是一门面向对象的语言,正因为如此,在Python中创建一个类和对象是很容易的.本章节我们将详细介绍Python的面向对象编程. 如果你以前没有接触过 ...

  10. 配置 yum 源相关

    1. 修改yum配置 http://www.cnblogs.com/shuaixf/archive/2011/11/30/2268496.html 2. centos安装 epel 源 https:/ ...