Как перегрузить конструктор объекта в JS (Javascript)?

Могу я сделать что-нибудь вроде?:

function User(form) {
    this._username = form.username.value;
    this._password = form.password.value;
    this._surname = form.surname.value;
    this._lastname = form.lastname.value;
    this._birthdate = form.b_day.value+"-"+form.b_month.value+"-"+form.b_year.value;
    this._avatar = form.avatar;
    this._messages = new Array();
    this._messagesCount=0;
}

function User(userName,password,surname,lastName,birthdate) {
    this._username = userName;
    this._password = password;
    this._surname = surname;
    this._lastname = lastName;
    this._birthdate = birthdate;
    this._avatar = form.avatar;
    this._messages = new Array();
    this._messagesCount=0;
}
43
задан Fluffy 3 January 2012 в 18:46
поделиться