I just started using nodeJS and I am having some difficulties understanding the variable scope and referencing. For example in the code below, variable a will change/be overwritten even though the slice was made to variable b. My question is, how could I copy variable a into variable b without referencing it/overwriting variable a.
var a = ['a', 'b', 'c', 'd'];
var b = a;
b.splice(3,1);
console.log(a) //will display ['a', 'b', 'c'] instead of ['a', 'b', 'c', 'd']