Updating localstorage arrays in Javascript

前端 未结 2 1253
挽巷
挽巷 2021-01-21 18:19

I\'m trying to store and update an array in the localstorage using JSON.parse/stringify. But it doesn\'t seem to be working.

    yesArray = JSON.parse(localStora         


        
2条回答
  •  感情败类
    2021-01-21 18:46

    This seems to be the problem with passing the key of local storage without quotes.

    While reading from local storage use the key as argument as it stores the value as key/value pairs.

    yesArray = JSON.parse(localStorage.getItem("yesArray"));
    

提交回复
热议问题