Comment

Comment by andrewstuart2

"By reference" means different things to different people.

The most accurate statement I've found is that JavaScript, much like Java, passes reference-by-value. Everything is passed by value, but if your value is an object, then the new scope gets a copy of the reference. If you modify the object by dereferencing (that is, `a.foo = "bar";`), your modifications to the object persist outside of your scope.

This is an important understanding to have when working with JavaScript.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton