'javascript array passed by reference but [duplicate]

Why console.log(a) doesn't return same result [1, 2, 3, 4] as console.log(b) ?

function test(c, d) {
  c = [1, 2, 3, 4];
  d.push(4);
}

a = [1, 2, 3];
b = [1, 2, 3];
test(a, b);
console.log(a);
console.log(b);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source