I currently have the following code:
var myArray = []; var myElement = { id: 0, value: 0 } myElement.id = 0; myElement.value = 1; myArray[0] = myElement
This is a textbook case for a constructor function:
var myArray = []; function myElement(id, value){ this.id = id this.value = value } myArray[0] = new myElement(0,1) myArray[1] = new myElement(2,3) // or myArray.push(new myElement(1, 1))