Einfach "Klasse" Instanziierung

Von John Resig blog:

//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 );
  };
}

besonders diese Zeile this.init.apply( this, args.callee ? args : arguments );

Was ist der Unterschied zwischen args und arguments? Kann args.callee je false?

  • classic, // makeClass - Von John Resig (MIT Lizenz)
Schreibe einen Kommentar