I'm trying to create a 0 initialized 2d array. I have two tests that should be identical, but they are not. Any modification to test1[x] will result in all test1[x] entries to match. Why are all sub-arrays of test1 the same?
Note: Running this on codepen, all sub-arrays after the first say [circular object Arrray]
Link to codepen: https://codepen.io/tannyr/pen/qXLmeG?editors=1111
var test1 = Array(2).fill(Array(2).fill(0))
var test2 = [[0,0],[0,0]]
test1[0][0] = 1 // <= Should edit a single value
test2[0][0] = 1
console.log(test1[0], test1[1]) // [1, 0] [1, 0] <= Should match test 2
console.log(test2[0], test2[1]) // [1, 0] [0, 0]