Compare these two constructors:
A
var Person = function(name, age) {
this.name = name;
this.age = age;
}
B
var Person = function(name, age) {
var o = new Object();
o.name = name;
o.age = age;
return o;
}
Is there a downside to using B over A (other than brevity)?
Edit: The reason I ask is because I can learn by comparing and contrasting the two, not because I want to use B.
var Person = {name:name,age:age};as that is basically all you are ending up doing