I need to make a copy of an array without using reference
Example
var a = ["teste", "teste1"];
var b = a;
a[0] = "teste3";
b[0] = "teste4";
console.log(a) //mostrar teste3
console.log(b) //mostrar teste4
I need to make a copy of an array without using reference
Example
var a = ["teste", "teste1"];
var b = a;
a[0] = "teste3";
b[0] = "teste4";
console.log(a) //mostrar teste3
console.log(b) //mostrar teste4
For arrays using es6 you can do this:
var a = ["teste", "teste1"];
var b =[...a];
a[0] = "teste3";
b[0] = "teste4";
console.log(a) //mostrar teste3
console.log(b) //mostrar teste4