Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how To store array of object in local storage

//To store array of object in local storage

var msgObj ={
            'msg': 'Kiran G',
            'date':new Date().toLocaleString().replace(",", "")
           
        }
let msgArr = JSON.parse(localStorage.getItem('msg')) ? JSON.parse(localStorage.getItem('msg')) : []
msgArr.push(msgObj)
localStorage.setItem('msg', JSON.stringify(msgArr))
Source by gist.githubusercontent.com #
 
PREVIOUS NEXT
Tagged: #To #store #array #object #local #storage
ADD COMMENT
Topic
Name
3+8 =