📜  如何在javascript代码示例中使用指定值初始化和填充数组

📅  最后修改于: 2022-03-11 15:02:03.450000             🧑  作者: Mango

代码示例1
// how to Initialize and fill an array with the specified values in javascript
const initializeArrayWithValues = (n, val) =>
  Array.from({length: n}).fill(val);
  console.log(initializeArrayWithValues(4, 9)); // [ 9, 9, 9, 9 ]