I don’t know if it was a typo here, but the object window that’s all
lower case (you capitalized the "W", which will result in
error).
You don’t need to use JSON parse, just put it on localStorage the direct array it is already saved in string form.
That is, when using:
var pessoa = ["Bonito","Alto","Magro"];
window.localStorage.setItem('pessoa', pessoa);
The value of localStorage will be the array in string form:
"Bonito","Alto","Magro"
And to recover you use .getItem() and .split(",") to convert to array again (if there is no comma in the middle of the words in the array):
var pessoaAntiga = window.localStorage.getItem('pessoa').split(",");
This method should be used carefully, if any string in the array contains comma, the
splitwill not return the expected value. And just to be explicit, it is not thatWindowbe wrong, butWindowrefers to the type (constructor function), equatorwindowthe value (object)– Costamilam
True friend. I will reevaluate the answer. Obg!
– Sam