I seem to be encountering an issue with this 2-dimensional array in JavaScript. It appears that when I modify a[1][0]
, the value of a[0][0]
also changes. Could it be a problem with how I am initializing it? If so, what is the correct way to initialize it to avoid this issue?
>var a = Array(100).fill(Array(100).fill(false));
>a[0][0]
>false
>a[1][0]
>false
>a[1][0] = true
>true
>a[1][0]
>true
>a[0][0]
>true