📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
JavaScript SessionStorage Methods
- setItem(): Add key and value to SessionStorage
- getItem(): Retrieve a value by the key from SessionStorage
- removeItem(): Remove an item by key from SessionStorage
- clear(): Clear all SessionStorage
- key(): Passed a number to retrieve nth key of a SessionStorage
Syntax
window.sessionStorage
sessionStorage.setItem("key", "value");
var lastname = sessionStorage.getItem("key");
sessionStorage.removeItem("key");
sessionStorage.clear();
var KeyName = sessionStorage.key(index);
JavaScript SessionStorage Example
sessionStorage.setItem("firstName", "Ramesh");
var user = {
firstName : "Ramesh",
lastName : "Fadatare"
}
sessionStorage.setItem("id", JSON.stringify(user));
sessionStorage.getItem('id');
"{"firstName":"Ramesh","lastName":"Fadatare"}"
sessionStorage.removeItem('id');
sessionStorage.clear();
Comments
Post a Comment
Leave Comment