I have code like this:
var a = "a";
var b = a;
a = "b";
console.log(a);
console.log(b);
Output:
a
b
The problem occured when I changed the variable into an array, the value in b also changed when I changed a.
The code like this:
var a = new Array(1);
a[0] = "a";
var b = new Array();
b.push(a);
a[0] = "b";
console.log(a);
console.log(b);
Output:
["b"]
[["b"]]
I want the result like this:
Output:
["b"]
[["a"]]
What should I do?