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
Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.
✨ Frag Lara — deine KI-Lernpartnerin
Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.
Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

