I declare a 2-dimensional array
var arr = new Array(4).fill([])
// arr = [[],[],[],[]]
When I want to push a value to one of its elements, it cause others do the same
arr[0].push(1)
// arr = [[1],[1],[1],[1]]
Why that happend, how to fix it?
I declare a 2-dimensional array
var arr = new Array(4).fill([])
// arr = [[],[],[],[]]
When I want to push a value to one of its elements, it cause others do the same
arr[0].push(1)
// arr = [[1],[1],[1],[1]]
Why that happend, how to fix it?