"new Object()", here's an example:
function User(name, age){
//if ( !(this instanceof User) )这个也是可以工作的, 但是arguments.callee更通用
if ( !(this instanceof arguments.callee) )
return new User(name, age);
this.name = name + " - " + age;
}
var user = User("xlty", 27); <==> var user = new User("xlty", 27);
No comments:
Post a Comment