Using new Array methods and =>
function syntax from ES6 standard (only Firefox at the time of writing).
By filling holes with undefined
:
Array(N).fill().map((_, i) => i + 1);
Array.from
turns "holes" into undefined
so Array.map
works as expected:
Array.from(Array(5)).map((_, i) => i + 1)