Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can we add and remove data from local storage?

user-image
Question added by Faten Almajaly
Date Posted: 2015/03/24
Shahid Riaz Bhatti
by Shahid Riaz Bhatti , Principal Software Engineer (Team Lead) , Sunstar Technologies Pvt Ltd

Set data as follow:-

 

localStorage.setItem("Key", value);

 

and to get Item from local storage

 

localStorage.getItem("key");

 

Also check if browser supports local storage before using it. It will look something like this:-

 

if(Storage == undefined || typeOf(Storage) == "undefined")

{

alert("Storage is not supported")

}

else

{

// Get or Set Item

}

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.