---
title: "Discussion on \"JavaScript Variables Explained Clearly: Values, Types, and How Data Really Works\" | Hashnode"
description: "Discussion on \"JavaScript Variables Explained Clearly: Values, Types, and How Data Really Works\". Learn how JavaScript variables work, including let vs const, primitive and reference types, pass by value, and how JavaScript stores data in memory."
url: "https://hashnode.com/posts/javascript-variables-explained-values-references/697a04549209c33467e84027"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JavaScript Variables Explained Clearly: Values, Types, and How Data Really Works](https://blog.greenroots.info/javascript-variables-explained-values-references?utm_source=hashnode&utm_medium=feed)

Learn how JavaScript variables work, including let vs const, primitive and reference types, pass by value, and how JavaScript stores data in memory.

Jan 28 · 5 min read · blog.greenroots.info  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#beginners](https://hashnode.com/tag/beginners)
-   [#programming](https://hashnode.com/tag/programming)
-   [#codenewbies](https://hashnode.com/tag/codenewbies)

## Written by

[Tapas Adhikary](https://hashnode.com/@atapas)

@atapas · Bangalore

  
[View profile](https://hashnode.com/@atapas)

Educator @tapaScript | Founder CreoWis & ReactPlay - Writer - YouTuber - Open Source

Co-Founder, @CreoWis | Teacher, @tapaScript | Founder, @ReactPlay | YouTuber | Writer | Human

## Responses 1

Markdown supported · ⌘↵ to post

[max](https://hashnode.com/@maxxmini)

[Mar 8](https://hashnode.com/posts/javascript-variables-explained-values-references/697a04549209c33467e84027/comment/69ad0753536b8710ef17d3d5)

Really appreciate how you broke down the difference between primitive and reference types — that 'copying a reference vs copying a value' distinction trips up so many developers.

I've been building a financial tracking app (IndexedDB-based, runs entirely in the browser) and ran into a subtle bug where I was mutating an object I thought I'd cloned. Turned out I was just copying the reference. A simple `structuredClone()` fixed it, but it cost me hours of debugging.

Question: when you're teaching this concept, do you find students grasp it better with memory diagrams (boxes and arrows) or through live mutation examples in the console? Curious because I've seen both approaches and wonder which sticks better.
