var myarray = []
var array1 = [1,2,3]
myarray.push(array1)
array1 =[2,3,4]
myarray.push(array1)
console.log(myarray)
I get
[ [ 1, 2, 3 ], [ 2, 3, 4 ] ].
Shouldn't it be
[ [ 2, 3, 4 ], [ 2, 3, 4 ] ]
if I am passing by reference?
Thank you
edit: I am guessing it is because = [2,3,4] creates a new object and assigns array1
to refer to it rather than vice versa