declare an array of length n javascript code example
Example 1: es6 create array with increasing number
Array.from(Array(10).keys())
Example 2: array length javascript
var numbers = [1, 2, 3, 4, 5];
var length = numbers.length;
for (var i = 0; i < length; i++) {
numbers[i] *= 2;
}
Example 3: javascript fill array with range
function range(start, end) {
return Array(end - start + 1).fill().map((_, idx) => start + idx)
}
var result = range(9, 18);
console.log(result);
Example 4: js init array length
new Array(4);