3 ms·
I work full-time in JavaScript and I've always thought of JavaScript as a pass-by-reference but this article made it clear that JavaScript is pass-reference-by-
by Osiris 12y ago
I work full-time in JavaScript and I've always thought of JavaScript as a pass-by-reference but this article made it clear that JavaScript is pass-reference-by-value. The `swap` function from the article doesn't swap the variables outside of the function.
- jacquesm 12y agojavaScript != java...
- rcconf 12y agoThe behaviour of JavaScript is equivalent for references. (Call by sharing)
- Osiris 12y agoYes, but the way function parameters are passed is the same. I wrote the swap function in JavaScript and it behaves exactly like the Java version, as opposed to the true "pass by reference" examples.