Let's say we have a variable a. We want to save it for later, so we make a copy of it with .slice(0):
var a = [[1,2]]
var b = a.slice(0)
This should work, right? Well, if we do this:
var a = [[1,2]]
var b = a.slice(0)
console.log(b + " - before change")
a[0][1] -= 2
console.log(b + " - after change")
It returns:
1,2 - before change
1,0 - after change
However, if we change variable a to just [1,2] it works normally. Why does this occur?