Interview Question

What is sessionStorage?

sessionStorage stores origin-scoped strings for one page session.

💡 Concept ✅ Quick Revision ⚡ JavaScript

Answer

sessionStorage provides string key/value storage scoped to an origin and top-level browsing context. • Each tab or top-level context has its own page session. • Values are stored as strings. • The storage normally lasts for the page session.

Example

Code
sessionStorage.setItem('step', '2');
console.log(sessionStorage.getItem('step'));
Output
2

Quick Revision

sessionStorage stores origin-scoped strings for one page session.