Local Storage in JavaScript
localStorage lets you save data in the user's browser – even after closing the tab or restarting the computer. It's simple, synchronous, and great for small amounts of data like settings or progress.
Data is stored as strings and tied to the domain. Each site gets about 5-10 MB of space.
Saving Data with setItem
Retrieving Data with getItem
Storing Objects (JSON.stringify/parse)
localStorage only stores strings – use JSON to save objects or arrays.
Removing and Clearing
Practical Example: Theme Switcher
Limitations
- Only strings (use JSON for objects)
- About 5-10 MB limit per domain
- Synchronous (can block if overused)
- Same-origin policy – no cross-domain access
Quick Quiz
Hemos revisado y comprobado los materiales, pero aún pueden existir errores. El contenido se ofrece únicamente con fines educativos, así que úsalo bajo tu propia responsabilidad y verifica con otras fuentes si es necesario.
✨ Pregunta a Lara — tu compañera de estudio con IA
Desbloquea soporte de aprendizaje personalizado. Lara puede explicar lecciones, resumir temas y responder tus preguntas — disponible desde el plan Go y superiores.
Lara te ayuda a aprender más rápido — exclusivo para los miembros ReadyTools Go, Plus y Max.

