I thought initializing an multi dimensional array would be easy:
row = Array(4).fill(0)
block = Array(4).fill(row)
block[2][2] = 15
but that just creates an array of one row, 4 times, so if I assign block[2][2] = 15, then the whole column is 15.
(4) [Array(4), Array(4), Array(4), Array(4)]
0:(4) [0, 0, 15, 0]
1:(4) [0, 0, 15, 0]
2:(4) [0, 0, 15, 0]
3:(4) [0, 0, 15, 0]
I tried Array(4).fill(Array(4).fill(0)) but had the same result.
blockarray withrow, you're assigning the same object to every index.