Web Storage API

Sumit kumar Singh
Frontend Weekly

--

Web storage, also known as HTML5 storage or DOM storage, is a mechanism that allows web applications to store data locally in the user’s browser. This data is stored on the client side, meaning it is stored on the user’s device rather than on the server. Web storage is supported by most modern web browsers and provides an easy way for developers to store small amounts of data, such as user preferences, shopping cart items, or user session data.

There are two types of web storage: local storage and session storage.

Local storage:

Local storage allows web applications to store data without an expiration date. This means that data stored in local storage will persist even after the browser is closed, and can be accessed by the same web application on future visits. Local storage provides a maximum storage capacity of around 5–10 MB, depending on the browser.

Here’s an example of how to use local storage to store and retrieve data in JavaScript:

To store data in local storage, use the following code:

localStorage.setItem('key', 'value');

This code sets a key-value pair in local storage. The key is a string that represents the name of the data, and the value is the actual data being stored.

--

--

Sumit kumar Singh
Frontend Weekly

YouTube: https://www.youtube.com/@tech..Design/ 📚 HTML,Angular, React,and JavaScript 🧑‍💻 Tips & tricks on Web Developing 👉 FULL STACK DEVELOPER