Array initialization

This commit is contained in:
Angelos Chalaris
2017-11-30 20:06:16 +02:00
parent 0b223c3b2d
commit 466325da13
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,9 @@
### Initialize array with values
Use `Array(n)` to create an array of the desired length, `fill(v)` to fill it with the desired value.
You can omit `v` to use a default value of `0`.
```js
var initializeArray = (n, v = 0) =>
Array(n).fill(v);
```