相关疑难解决方法(0)

680
推荐指数
19
解决办法
59万
查看次数

简单的"类"实例化

来自John Resig博客:

// makeClass - By John Resig (MIT Licensed)
function makeClass(){
  return function(args){
    if ( this instanceof arguments.callee ) {
      if ( typeof this.init == "function" )
        this.init.apply( this, args.callee ? args : arguments );
    } else
      return new arguments.callee( arguments );
  };
}
Run Code Online (Sandbox Code Playgroud)

尤其是这条线 this.init.apply( this, args.callee ? args : arguments );

args和之间有什么区别arguments?能args.callee永远false

javascript oop

10
推荐指数
1
解决办法
6848
查看次数

标签 统计

javascript ×2

closures ×1

oop ×1

static ×1

variables ×1