Filling an array with objects, objects lose structure

Filling an array with objects, objects lose structure

I'm filling an array like this:

  1. function myObject(newname, newid) {
  2.  var name = newname;
  3.  var id = id;
  4.  function SomeFunction() {}
  5.  return {
  6.   ID: function () { return id; },
  7.   Name: function () { return name; },
  8.   DoWork: SomeFunction,
  9.  }
  10. }
  11. 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.