🌐Local Storage
Also known as localStorage, Web Storage, Session Storage
A small store in the browser for a site's data. It stays after you close it.
Think of it like
Think of it like a small drawer in your own desk. A site can leave notes there, and they wait until it comes back.
Example
Emma's site remembers that Lucy chose dark mode. It saves theme=dark in local storage and reads it on her next visit.
Why it matters
It lets a site remember small choices without a server or a login.
Definition
Example code
javascript
localStorage.setItem("theme", "dark");
localStorage.getItem("theme"); // "dark"Common mistake
Key takeaways
- 1Stays in the browser. Never sent to the server.
- 2Lasts after closing. Until it is cleared.
- 3Not for secrets. Any script can read it.