So I have an object constructor, but when I try and put an object in, the array cmndlist
always has x amount of the last object defined. (Basically they all end up the same)
function command(name, category, help, callback) {
this.name = name;
this.help = help;
this.use = callback;
cmndlist[category].push(this);
};
Here's the code where I define the objects too.
command("foo",0,"foo", function(message){
//code
});
command("bar",1,"bar", function (message){
//code
});
command("foobar",1,"foobar", function (message){
//code
});
So in this example, all the objects in the array will have the same properties as foobar
.
I don't want that, I want it to have all three of the objects.