General WebQuestion 01 of 9
Web Storage
Answer out loud or in your head first, then compare.
Answer
localStorage keeps data for a given origin across sessions. sessionStorage is also tied to the tab's session. Both APIs store strings and work synchronously.
JavaScript
localStorage.setItem('settings', JSON.stringify({ theme: 'dark' }));
const settings = JSON.parse(localStorage.getItem('settings') || '{}');To be precise: the user or the browser can delete the data, and writing can fail. For larger, structured data, the asynchronous IndexedDB is a better fit.
Pitfall: storage is not a safe vault for secrets — any script running on that origin can read it. Unlike cookies, Web Storage data is not sent with requests automatically.
How did it go? Be honest — “Not yet” puts the question on your review list.