Skip to content
Learn Netverks

Lesson

Step 28/36 78% through track

json-localstorage

JSON and localStorage

Last reviewed May 28, 2026 Content v20260528
Track mode
client_javascript
Means
In-browser JS
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches JSON and localStorage—the ideas, syntax, and habits you need before moving on in JavaScript.

Without a solid grasp of JSON and localStorage, you will repeat mistakes in JavaScript exercises and on real pages or scripts.

You will apply JSON and localStorage in contexts like: Browsers, Node.js services, edge workers, and tooling ecosystems (bundlers, test runners).

Run JavaScript in the in-browser sandbox, use the terminal output panel, and verify with MCQs.

Toward the end of the track—use it to consolidate patterns before the capstone or summary lessons.

JSON.stringify / parse serialize objects. localStorage persists key-value strings in the browser (not for secrets).

localStorage limits

~5MB per origin, synchronous API—blocks main thread on large data. Never store tokens without understanding XSS risk.

sessionStorage

Same API but cleared when tab closes.

Important interview questions and answers

  1. Q: JSON dates?
    A: Serialized as strings—revive manually if needed.
  2. Q: localStorage secure?
    A: No—any script on page can read; HttpOnly cookies for session tokens.

Self-check

  1. Why not store JWT in localStorage?
  2. What does JSON.stringify skip?

Pitfall: Never store refresh tokens in localStorage on public sites.

Interview prep

JWT in localStorage?

Risky with XSS—prefer HttpOnly cookies for sessions.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What would you log to verify this behavior?
  • What breaks if you run this before the DOM is ready?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump