Summary of some skills of Array usage in JavaScript

1. Create an array of all 0s and length 100 (ES6)

Array(10).fill(0)

2. Create an array of length 100, which stores 0 ~ 99

let array = Array(100).fill(0).map((item, index) => index);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324447951&siteId=291194637