Sometimes I need a more complex object in JavaScript and I usually do something like this.
var myVar = ArrayWithMetaData(GetStringArray(),{description: "These are numbers", ...});
function ArrayWithMetaData(arr, params){
var temp = params;
for(var i = 0; i < arr.length; i++)
temp[i] = arr[i];
return temp;
}
//TODO: Returns an array i.e. ["one", "two", "three"], may be very large
function GetStringArray() {}
Is there a shorter method of accomplishing this or is there a library that provides similar functionality?
Also, is there a name for this type of javascript variable?
Another option is to define an object with straight json, where the array is one property, like:
Then you would just access the array using
myVar.values.