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.
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.
When I worked on my Leaf language I called things
shared
to denote the sharing. It followed this pattern quite closely.