Диапазон JavaScript
[...Array(5).keys()];
=> [0, 1, 2, 3, 4]
arvinreydelapena
[...Array(5).keys()];
=> [0, 1, 2, 3, 4]
// n is your max range
[...Array(n).keys()]
let n = 10
[...Array(n).keys()] // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
var list = [];
for (var i = lowEnd; i <= highEnd; i++) {
list.push(i);
}
for (i of range(1, 5)) {
console.log(i);
}
/* Output
* 1 2 3 4 5 */
[...range(1, 5)] // [1, 2, 3, 4, 5]
function scale (number, inMin, inMax, outMin, outMax) {
return (number - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
}
[...Array(5).keys()] // [0, 1, 2, 3, 4]