Sometimes we need to store an array at client side so the best way to store array in localstorage just like temp storage container. So here is code.
localStorage only supports strings. Use JSON.stringify() and JSON.parse().
localStorage only supports strings. Use JSON.stringify() and JSON.parse().
var names = []; names[0] = prompt("New member name?"); localStorage["names"] = JSON.stringify(names); //... var storedNames = JSON.parse(localStorage["names"]);
No comments:
Post a Comment