Can I do something like?:
function User(form) {
this._username = form.username.value;
this._password = form.password.value;
this._surname = form.surn
Overload the constructor or any other Javascript function by counting the number of arguments:
function FooString()
{ if(arguments.length>0)
{ this.str=arguments[0];
return;
}
this.str="";
}
var s1=new FooString;
var s2=new FooString("hello world");
You can also set default arguments by detecting how many arguments are missing.