參考:http://ejohn.org/blog/simple-class-instantiation/約翰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);
};
}
我想知道,是否有實現相同功能的任何的ECMAScript 5標準的方式。問題是,訪問arguments.callee
在嚴格模式下不推薦使用。