Is there a way I can do all of this in a constructor?
obj = new Object(); obj.city = \"A\"; obj.town = \"B\";
Why don't you just do it this way:
var obj = {"city": "A", "town": "B"};
Do not complicate things. Here is a simplest way of defining a constructor.
var Cont = function(city, town) { this.city = city; this.town = town; } var Obj = new Cont('A', 'B');