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"};