views:

46

answers:

2

ok, so when i do array=array2 then change something in array2 it changes array. how do i prevent this?

+2  A: 

Do..

b = a.slice()

Why? Because assignment would just reference the origin object. slice or concat would create a new object.

meder
+1  A: 

var b = a.concat();

glebm