localStorage
only supports strings. Use JSON.stringify()
and JSON.parse()
.
var names = []; names[0] = prompt("New member name?"); localStorage.setItem("names", JSON.stringify(names)); //... var storedNames = JSON.parse(localStorage.getItem("names"));
You can also use direct access to set/get item:
localstorage.names = JSON.stringify(names); var storedNames = JSON.parse(localStorage.names);
Related Posts:
- HTML5 Local storage vs. Session storage
- Showing an image from an array of images – Javascript
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- For-each over an array in JavaScript
- How do I check if an array includes a value in JavaScript?
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Maximum call stack size exceeded error
- How to properly use jsPDF library
- Can I use complex HTML with Twitter Bootstrap’s Tooltip?
- Loop through an array in JavaScript
- Google Chrome Uncaught (in promise) DOMException while playing AUDIO
- How can I remove a specific item from an array?
- Find object by id in an array of JavaScript objects
- How can I access and process nested objects, arrays or JSON?
- How to make a word underline in Markdown
- ChartJS beginAtZero, min, max doesn’t work
- How do I check whether a checkbox is checked in jQuery?
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- Cannot set property InnerHTML of null [duplicate]
- ReferenceError: $ is not defined
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- How do I check whether a checkbox is checked in jQuery?
- jQuery document.createElement equivalent?
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- Split string into array
- How can I remove a specific item from an array?
- How to make a word underline in Markdown
- Array.size() vs Array.length
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- Sort array of objects by string property value
- How to play audio?
- Copy array by value
- How can I reverse an array in JavaScript without using libraries?
- How to play audio?
- What is the way of declaring an array in JavaScript?
- How can I scroll to an element using jQuery?
- jQuery.click() vs onClick
- jQuery Get Selected Option From Dropdown
- How to create an associative array in JavaScript literal notation
- Include another HTML file in a HTML file
- Remove duplicate values from JS array [duplicate]
- How can I create a two dimensional array in JavaScript?
- Check if checkbox is checked with jQuery
- How to loop through an array containing objects and access their properties
- Get the last item in an array
- How do I empty an array in JavaScript?
- Remove duplicate values from JS array
- How can I create a two dimensional array in JavaScript?
- Add swipe left/right to web page, but use default swipe up/down
- How to add jQuery code into HTML Page
- How can I get the data-id attribute?
- Check if checkbox is checked with jQuery
- How to loop through an array containing objects and access their properties
- Get the last item in an array
- How to filter an array/object by checking multiple values
- How do you check if a variable is an array in JavaScript?
- How to resolve the C:\fakepath?
- How do I empty an array in JavaScript?
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- How to find the sum of an array of numbers
- Angular: mat-form-field must contain a MatFormFieldControl
- Remove Object from Array using JavaScript
- Short circuit Array.forEach like calling break
- (change) vs (ngModelChange) in angular
- Bootstrap Dropdown menu is not working
- Remove duplicate values from JS array
- How to check if array is empty or does not exist?
- Why is using “for…in” for array iteration a bad idea?
- jquery SlideToggle effect in upward direction?
- Deleting array elements in JavaScript – delete vs splice
- Change Background color (css property) using Jquery
- Filter array to have unique values
- How to randomize (shuffle) a JavaScript array?
- How to compare arrays in JavaScript?
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- Better way to sum a property value in an array
- How to clear the canvas for redrawing
- Adding options to select with javascript
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- Set timeout for ajax (jQuery)
- How does the data-toggle attribute work? (What’s its API?)
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- CSS height 100% percent not working
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- Merge/flatten an array of arrays
- JavaScript get element by name
- Use images like checkboxes
- How to read xml file contents in jQuery and display in html elements?
- Completely disable scrolling of webpage
- TypeError: Cannot Set property ‘onclick’ of null
- How to print elements from array with javascript
- Express Render not working return error: No default engine was specified and no extension was provided
- How do I scroll to an element using JavaScript?
- Remove Object from Array using JavaScript
- What is the difference between ( for… in ) and ( for… of ) statements?
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- Jquery swipe left or right on mobile