create range array javascript
[...Array(10).keys()]
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]function range(start, end) {
return Array(end - start + 1).fill().map((_, idx) => start + idx)
}
var result = range(9, 18); // [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
console.log(result);for (i of range(1, 5)) {
console.log(i);
}
/* Output
* 1 2 3 4 5 */
[...range(1, 5)] // [1, 2, 3, 4, 5]
Also in JavaScript:
- js replace all symbols in string
- nodejs include json file
- js loop through associative array
- include gif in react
- javascript 1 + "1"
- react native slow performance after load iamges
- javascript keydown
- client timezone offset in JavaScript
- update photoURL firebase
- jquery loop over elements
- jest simulate toggle switch react native
- redis nodejs
- keyboard close when typing react native
- queue data structure in javascript 2018
- javascript int values
- js check if array
- javascript on url anchor change event
- js set iframe src
- javacript is checkbox checked
- stream recording javascript
- dotenv
- angularjs class directive prepend
- jquery table row calculation
- vuejs how use this.$slots.default