DEV Community

loading...

Discussion on: 🛸 Is JavaScript using pass by value or pass by reference? Let's find out!

Collapse
gypsydave5 profile image
David Wickes

Is JavaScript using pass by value or pass by reference?

Neither. It's call by sharing. Same as Python, Ruby and many others.

The evaluation model you (and many others) describe for JavaScript is both inaccurate and overcomplicated. This way of describing it seems to have been chiefly promoted by Java developers (who really do have primitives and have to worry about boxing etc.) when they blog about JavaScript or learn JavaScript. And there's a lot of Java developers, so this complicated myth has drowned out the simple truth.

Collapse
mortoray profile image
edA‑qa mort‑ora‑y

When I worked on my Leaf language I called things shared to denote the sharing. It followed this pattern quite closely.