Caffeinated Coder
Book an appointment
Lesson 24 · JavaScript in the browser

Storage in the browser

A page's variables vanish when it reloads, but localStorage keeps small pieces of text in the browser, one store per website. Follow a page that counts your visits: getItem finds nothing the first time, setItem stores the string "1", a reload empties memory but not storage, and the second visit reads "1" back, turns it into a number and stores "2".

10 min11 steps5 questionsIntermediate
Fig 24 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.