LocalStorage
Web LocalStorage
A browser storage API providing 5-10 MB of key-value storage per origin, persisting across sessions.
Detalle técnico
LocalStorage is part of the web platform's core infrastructure. Modern browsers implement browser through standardized Web APIs, ensuring consistent behavior across Chrome, Firefox, Safari, and Edge. The relevant specifications are maintained by the W3C, WHATWG, or IETF. Understanding the underlying protocol or mechanism helps developers use localstorage correctly, avoid common pitfalls, and optimize for performance and security.
Ejemplo
```javascript
// JSON parse with reviver function
const data = JSON.parse(text, (key, val) => {
if (key === 'date') return new Date(val);
return val;
});
// JSON stringify with replacer and indentation
JSON.stringify(data, ['name', 'email'], 2);
```