Javascript | Set all values of an array

前端 未结 8 884
清酒与你
清酒与你 2020-12-29 19:45

Code

var cool = new Array(3);
cool[setAll] = 42; //cool[setAll] is just a pseudo selector..
alert(cool);

Result

8条回答
  •  心在旅途
    2020-12-29 20:05

    It's 2019 and you should be using this:

    let arr = [...Array(20)].fill(10)

    So basically 20 is the length or a new instantiated Array.

提交回复
热议问题