Here is my object construction,
function Employee(name, dob) {
this.Name = name;
this.DateOfBirth = new Date(dob);
}
Now, I have created an instance for this, like
var emp = new Employee("sample","12/12/12");
Its working fine when i print the output.
But, if i create the object like
var emp = new Employee(name = "sample");
or
var emp = new Employee(dob = "12/12/12");
its not working fine. In both the cases, the DateOfBirth
field is invalid.
I need to define an object with optional parameters.