Engrain by ByteRush

WEB.05.02 JuniorCore — asked often

localStorage, sessionStorage and IndexedDB

Comes up in: Web fundamentals, Recruiter screen

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • sync string API vs async structured storage
  • per-origin scope
  • sessionStorage per tab
  • storage event across tabs
  • IndexedDB transactions, object stores, indexes (with a wrapper library)
  • never store tokens in localStorage if XSS is a risk (trade-off discussion)

Words you will know

Web StorageIndexedDBobject storetransaction

What you will practise

  • offline notes app with IndexedDB

Interview questions this answers

  • Compare cookies, localStorage, sessionStorage and IndexedDB.
  • Where should you store an auth token in a SPA? What are the trade-offs?
  • How do you sync state between tabs?