An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
October 22, 2021 08:19 am GMT
Original Link: https://dev.to/coderduck/simple-way-to-store-data-in-js-1i3
simple way to store data in js
You want a simple way to store data? In javascript, you can use window.localStorage
.
localStoge allows you store any information in browser. It is new feature of HTML5, and using method is similar to hashmap(with key and value). To store data, use this syntax:
localStorage.setItem(key, value);
And to get data, use:
localStorage.getItem(key);
localStorage also provide method to delete data:
localStorage.removeItem(value); //delete onelocalStorage.clear(); //delete all
Read more about document: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Because it's pretty basic and simple, localStorage only store string data, if data is more complex, it becomes useless. Addition, the limit of data is small(about 5mb); and it has not security. Therefore, think carefully before use localStorage.
Original Link: https://dev.to/coderduck/simple-way-to-store-data-in-js-1i3
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To