Save array or object in localstorage javascript

You need to convert array/object to string first. You can’t save array in localstorage. It saves string Only.

To convert array to string, use:

To get array back from string, use:

Example:

 

 

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *