How does html 5 web storage work ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How does html 5 web storage work ?

Explain with the help of a example by storing a value as I was not able to understood it properly in Solo Learn .😦😮😢

25th May 2017, 12:16 AM
Prajwal Agarwal
Prajwal Agarwal - avatar
2 Answers
+ 4
html5 storage has 2 API, sessionStorae and localStorage. They are very much similar and the main difference is how long data persist in the users browser. example with localStorage: localStorage.setItem(key, value["string"]) the above stores a data into the browsers localStorage. It requires a key and a value pairs. Just like explicitly constructing objects where you have property and a value. So for example: var book_id = 1; var book = "SoloLearn Fundamentals"; to store the above: localStorage.setItem(book_id, book); to view the stored object, open browser's devtools, Application Tab and then local storage. to get back the object: localStorage.getItem(key) or localStorage.key(index) Practice along as you read through the fundamental again you surely will understand the above.
25th May 2017, 3:26 AM
Benneth Yankey
Benneth Yankey - avatar
+ 1
Thanks Ben 👍
25th May 2017, 3:44 AM
Prajwal Agarwal
Prajwal Agarwal - avatar