Filling an array with objects, objects lose structure
I'm filling an array like this:
- function myObject(newname, newid) {
- var name = newname;
- var id = id;
- function SomeFunction() {}
- return {
- ID: function () { return id; },
- Name: function () { return name; },
- DoWork: SomeFunction,
- }
- }
- var myArray = new Array(new myObject("value1","1"), new myObject("value2","2"));
But when I go back to get them (myArray[0]) the object I get doesn't have the structure and values I put in.
Is there a better way to do this?
I'm using jquery 2.1.3 in a Windows Store app.