I'm trying to work with javascript objects, but not getting very far. Any ideas why this doesn't work?
function Tracking(){ var choices = new Array(); } Tracking.prototype.getChoice = function (key){ return this.choices[key]; } Tracking.prototype.setChoice = function (choice){ this.choices.push[choice]; } function TrackingChoice(key, choice){ this.key = key; this.choice = choice; } .....
var tracking = new Tracking(); var choices = new Array(); choices.push(new TrackingChoice("purchase", true)); choices.push(new TrackingChoice("listing", false)); choices.push(new TrackingChoice("offers", false)); choices.push(new TrackingChoice("messages", false)); tracking.setChoice(choices); var a = tracking.getChoice(0); var a is empty as the choices array in the Tracking object are still null. This confuses me.