What is going on when you use Array(n).fill(Array(m).fill('_')) and you try to change 1 field, it changes multiple

前端 未结 0 557
遥遥无期
遥遥无期 2021-01-07 04:59

Example:

let arr1 = Array(8).fill(Array(8).fill(\'_\'))

arr1[3][5] = \'N\'

console.log(arr) /* [
   ["_", "_", "_", "_&qu         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题