I\'m creating a dungeon crawler game using React.js and I was initializing the board using Array.fill(0). but when I set an element inside the 2d array it sets the entire Ar
You can fill 2D array with a help of Array.fill in a such way:
let arr = Array(5).fill(0).map(x => Array(5).fill(0))