Key-Value pairs can be created with JavaScript Objects, with Object lietral, like this
{key: value}
Arrays can be created with Array literal (
[]
) or withArray
constructor like thisnew Array(size);
You can use both of them, like this
var array = [];
array.push({key1: value1});
Since JavaScript arrays begin with index 0, you need to access the first element with index 0, second with 1 and so on.
console.log(array[0]);
will print the first key-value pair stored at index 0.