Say i have
function Person(birthDate){ // parameter accepting is unknown to the alias maker
this.birthDate = birthDate;
this.getAge = function() {
return new Date().getFullYear() - this.birthDate.getFullYear();
};
};
i simply gave function name 'Person' to some-body, who does not know how many arguments Person can accept, and asked him to make alias of Person
That alias should work the same way as Person
var dave = new Alias_Person(new Date(1909, 1, 1)); // here number of parameters is unknown
dave.getAge(); //returns 100.
What should be alias?
Please note that, the alias should have its own function and not just the reference of Person
Currently i do,
var Alias_Person = function(){
return Person.apply(null, arguments);
};
But that doesn't return right result.
EDIT : my end aim is to get rid of 'new' to be used with Date. simply using Date() always result into current date and time. I want something like this
My_Date({parameters}) to return the same result as that with 'new Date({parameters})'