The Web Storage API provides browser-side key-value persistence through localStorage. Interview discussions focus on persistence, compatibility, serialization, storage limits, synchronous operations, and security. section 2.3
A practical localStorage workflow includes:
- Check that window.localStorage exists before using the API. section 2.3
- Store values with setItem(key, value), retrieve them with getItem(key), and remove individual entries with removeItem(key). section 2.3
- Use clear() to remove all stored data and avoid placing sensitive information in local storage. section 2.3
Serialization matters
localStorage.setItem("num", 123) stores "123". Directly storing an object produces "[object Object]", demonstrating that values are stored as strings and require deliberate serialization. section 2.3


