An interactive, dependency-free simulator for explaining how JavaScript and Node.js variables behave in memory. The repository is designed to work as a small standalone learning object: learners can step through scenarios, inspect a conceptual stack/heap view, read a conceptual memory table, and review the included learning notes. The app supports both English and Estonian.
The app visualizes:
- primitive value copying
- object reference copying
- stack frames and local bindings
- heap objects and mutations
- function arguments
constbinding behavior- closures retaining environments
- variable shadowing
- primitive and data structure reassignment
- mutation versus reassignment
- reference copy versus shallow copy
- nested object references
The memory table is intentionally conceptual. It explains observable JavaScript behavior and should not be read as exact V8 or Node.js memory layout.
.
├── css/
│ └── styles.css
├── js/
│ └── app.js
├── index.html
└── README.md
Open index.html directly in a browser, or serve the folder with any static
server:
python3 -m http.server 4173Then visit:
http://localhost:4173
This repo includes a GitHub Actions workflow that publishes the static site to GitHub Pages.
- Create a new GitHub repository.
- Push this local repository to it.
- In GitHub, go to Settings -> Pages.
- Set Source to GitHub Actions.
- Push to
main; the workflow will deploy the site.
JavaScript is pass-by-value. The subtle part is that object values are references. When a function receives an object argument, it receives a copy of the reference, not a copy of the object.
That means:
- reassigning a primitive parameter does not change the caller's variable
- mutating an object through a copied reference changes the shared heap object
constprevents rebinding, but it does not freeze object contents
The visual model uses three main ideas:
- Call stack: active execution contexts, with the newest function call shown above its caller.
- Frames: conceptual containers for bindings, such as the global frame, function frames, and closure-related frames.
- Heap: conceptual storage for objects, arrays, functions, and retained closure environments that bindings can reference.