When attempting to save an array in localStorage, the values associated with String keys seem to disappear.
Here's an example:
var myArray = [];
myArray["key1"] = "value1";
myArray[123] = "value2";
Initially, everything seems to work fine and the expected output is attained:
myArray["key1"] => value1
myArray[123] => value2
However, when trying to store the array using this method:
localStorage.setItem('myStoredArray',JSON.stringify(myArray));
var myArray = JSON.parse(localStorage.getItem('myStoredArray'));
The result no longer includes the value linked to a String Key:
myArray["key1"] => undefined
myArray[123] => value2
Is there something incorrect in my approach? Should this be working as expected, or is there another way to save the array while retaining the values connected to String keys?
Any assistance would be greatly appreciated!