[Javascript] Create 2d array by using Array.from

  // Initialize a 2D array with zeros
  const str1 = "Hello"
  const str2 = "World"
  const dp = Array.from({ length: str1.length }, () =>
    Array.from({ length: str2.length }, () => 0)
  );

 

posted @ 2023-03-28 14:30  Zhentiw  阅读(12)  评论(0编辑  收藏  举报