Search
 
SCRIPT & CODE EXAMPLE
 

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))
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript stop the form from reloading 
Javascript :: typeorm config 
Javascript :: convert number to word j 
Javascript :: javascript create array of objects from multiple arrays 
Javascript :: npm registry 
Javascript :: javascript style font size 
Javascript :: currying javascript sum 
Javascript :: check if variable is jquery object 
Javascript :: javascript sort by date descending 
Javascript :: dynamic folder import javascript 
Javascript :: convert days into year month 
Javascript :: how to scroll smoothly in to the top in react js 
Javascript :: generate combinations of values from multiple array javascript 
Javascript :: how to setup atom for javascript 
Javascript :: unsubscribe all youtube channel using javascript 
Javascript :: 0.1+0.2 javascript 
Javascript :: Function used to reload the portion of a page using javascript 
Javascript :: js foreach 
Javascript :: npm chalk 
Javascript :: joi object id validation 
Javascript :: local storege in jquery 
Javascript :: reactjs cdn 
Javascript :: Razorpay generate Signature in the node js 
Javascript :: javascript ternary 
Javascript :: fetch method in js 
Javascript :: Creating a Node.js MySQL Database 
Javascript :: download jquery 
Javascript :: regex valid url 
Javascript :: passing livewire variable in alpine js 
Javascript :: cypress foreach li 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =