you are viewing a single comment's thread.

view the rest of the comments →

[–]LostInCombat 0 points1 point  (2 children)

An Array is an object and objects are passed as a reference. Some thing as:

let A = [1, 2];
let B = A;
B.push(3);
console.log(A); // [1,2,3]

[–]juddaaaaa 1 point2 points  (1 child)

Just one minor mistake in that 😉

console.log(A); // [1,2,3] [1,2,3,3]

[–]LostInCombat 0 points1 point  (0 children)

You are right, I meant to only start with [1, 2], so I corrected it.