This project explores the usage of client-side web APIs in JavaScript, focusing on client-side storage. The project is utilizing the Web Storage API for storing and retrieving data related to websites.
- All web storage data is contained within two object-like structures inside the browser:
sessionStorage
andlocalStorage
. - The
Storage.setItem()
method allows you to save a data item in storage.localStorage.setItem("name", "sunil");
- The
Storage.getItem()
method retrieves the value of a data item.let myName = localStorage.getItem("name"); myName; // Should display the value of the name data item.
- The
Storage.removeItem()
method removes a data item from web storage. jslocalStorage.removeItem("name"); myName = localStorage.getItem("name"); myName; // Should display null, as the name item no longer exists in web storage.
- Web storage data persists between page loads and even when the browser is closed (in the case of localStorage). This example demonstrates this persistence.
- Sunil K Joseph, Asst. Professor, Dept. of Computer Science, Mar Augusthinose College, Ramapuram.
This project was created as part of the Client-side web APIs tutorial provided by Mozilla Developer Network (MDN).