way to init two dimensional array

steyu·2022년 10월 20일
0
  1. init by Array.from


  1. init, shallow copy
const isVisited = new Array(rowLen).fill(new Array(colLen).fill(false));

// way to shallow copy two dimensional array
const newIsVisited = [];
isVisited.forEach((i) => newIsVisited.push(i.slice()));

0개의 댓글