+ 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 .😦😮😢
2 odpowiedzi
+ 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.
+ 1
Thanks Ben 👍