Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Deep-copying in JavaScript. Parent comment
If JavaScript allowed pass-by-referece, we would be able to do the following,
function swap(x, y) { let c = x x = y y = c } let a = {a: 6, b: 7} let b = {c: 8, d: 8} swap(a, b) console.log(b) // Object {a: 6, b: 7}
If JavaScript allowed pass-by-referece, we would be able to do the following,
Meaning, pass-by-reference means being able to actually change the "pointer" used by the local variable.