Array of fill method, easy to understand

Review react to see such a usage:

Array(9).fill(null); 

For this method for ES6, no impression, and now record it.

So this passage What does it mean?

Array (9) natural is the definition of an array of nine elements

All elements fill () method to fill an array index from start to finish with a static index value, the syntax is:

arr.fill(value)

arr.fill(value, start)

arr.fill(value, start, end)

Array (9) .fill (null) value is declare a full array of null.

Published 10 original articles · won praise 0 · Views 319

Guess you like

Origin blog.csdn.net/qq_30627241/article/details/104826766