Reference
Shared vocabulary for this workspace. Lessons stick to these meanings.
localStorage and
sessionStorage: synchronous string key/value maps with
small practical limits (~few MB). Exposed on Window only —
not available in workers.
sessionStorage data in a tab:
created when the document is loaded in that tab, kept for reloads/restores
while the tab stays open, destroyed when the tab closes.
sessionStorage /
localStorage: getItem, setItem,
removeItem, clear, key,
length. Keys and values are always strings.
localStorage, other same-origin
tabs hear it. For sessionStorage, only other same-origin
documents in the same tab (e.g. iframes) — not other tabs. The
document that made the change does not receive its own event.
window.open), the
new page’s sessionStorage is initially a copy of the
opener’s. After that they are separate: changes do not sync. Closing either
tab ends only that tab’s session data.
setItem cannot store the value (quota
full, or storage disabled). Always catch write failures; do not assume
infinite space.