I am recording acceleration data for the x-axis, so I have two values coming in – the x value, and the epoch time of the acceleration event. I want to store these as a hash, where the epoch time is the key and x-value is the value.
I created an array:
var arrX = new Array();
How can I add to it? Like this?
arrX[acceleration.timestamp] = acceleration.x
You should use an object, which can serve as a sort of “associative array” for this application. An object will provide support for the arbitrary, non-sequential keys that you mentioned, where an array would not.
More information: