tham khảo: http://ejohn.org/blog/simple-class-instantiation/John Resig của đơn giản lớp và "sử dụng nghiêm ngặt"
// 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);
};
}
tôi đã tự hỏi, nếu có bất kỳ ECMAScript 5 cách phù hợp để thực hiện các chức năng tương tự. Vấn đề là, việc truy cập arguments.callee
sẽ không được chấp nhận ở chế độ nghiêm ngặt.