Mr. Tono’s jar shelf is localStorage and each visitor’s tray is sessionStorage: save an object, a number or a token, see what the browser really keeps, then…
Why it matters
Misreading these stores breaks data quietly (an object becomes [object Object], a number becomes text), loses it when you do not expect (sessionStorage in a new tab), or lets others read it (a token in localStorage is read by any script on the page).
The key idea
Web Storage keeps text only, per origin, and sessionStorage per tab
Common mistakes
Saving an object straight into localStorage Storage only keeps text. setItem('k', obj) becomes '[object Object]'. Use JSON.stringify to write, JSON.parse to read.
Keeping an auth token in localStorage Any script on the page can read it, a malicious one through XSS included. Use an HttpOnly + Secure + SameSite cookie the server sets.
Relying on sessionStorage across tabs sessionStorage is per tab: a new tab starts empty. To share across tabs use localStorage (and the storage event to hear about changes).
Try it in this playground
Keep an object without JSON.stringify The jar cracks: what it holds becomes '[object Object]'.
Keep with JSON.stringify, read with JSON.parse The object comes back whole, keys and numbers.
Read sessionStorage from Bagas's tab A new tab, a new session: null. Its localStorage is the same.
Reload this page The page really reloads; the shelf and Rara's tray still hold their jars.