I was struggling to solve problem, after hours and a few sleeps I found a way around, but I still don't know why this happen.
Here is the code:
var array1 = [];
var array2 = [];
array1 = ["a","b","c","d","f"];
array2 = array1;
for(var i in array2){
if(array2[i]=="c"){
array2.splice(i,1);
}
}
console.log(array1);
console.log(array2);
When I log both arrays have the same exact values. I am only manipulating the second array, but it refletcs the first one.
Can anybody explain me why this happens ?