Posts

Showing posts from February, 2021

localstorage

 localstorage.setItem("rajiv","dahal")    here 'rajiv; is key and 'dahal ' is value  l ocalstorage..getItem("rajiv")    output is "dahal" localstorage.ramoveItem("rajiv")  the value is removed     problem in localstorage  const user={name:'rajiv'}  localstorage.setItem("name":user)  output:     here [object:object] will be shown in value but we want {name:rajiv'} so we use JSON for this type of problem   localstorage.setItem('name':JSON.stringify(user))            output:  'name'      {"'name'":"rajiv"}    localstorage.getItem("name")    output:  {'name':'rajiv'}  but we want{name:'rajiv'}    so to print output we use parse i.e JSON.parse(localstorage.getItem("name"))