: new:
function User(first,last,id){
User.Instance = User.Instance|| function(firstname,lastname,id){
this.firstname = firstname || 'nofirstname';
this.lastname = lastname || 'nolastname';
this.id = id || 0;
if (!User.Instance.prototype.nameUpper){
User.Instance.prototype.nameUpper = function(){
return this.name.toUpperCase();
};
User.Instance.prototype.resetId = function(){
this.id = 0; return this;
};
User.Instance.prototype.toString = function(){
return [this.id,': ',
this.firstname[0].toUpperCase(),
this.firstname.slice(1),
' ',
this.lastname[0].toUpperCase(),
this.lastname.slice(1)].join('');
};
}
}
return new User.Instance(first,last,id);
}
var pete = User('pete','johanssen',1),
jean = User('jean','harlowe',2),
mary = new User('mary','wsnovsky',3);
console.log(pete);
console.log(mary);
: " " /. " " ? , , , . , , new, . : ? ? chukj , , ?
, javascript, - . JSLint, , - :
jslint
, , jslint , , " ", " " .. , jslint " " .
javascript " javascript-". , , ( "" ). . , . . , . classes .
: , , " ". : .