Functional approach to basic array construction

Not in ES5, there’s no real functional equivalent to it, as you have to have something which has an amount of 20 to apply map to…

var my20ElementArray = [0,1,2,3,4,5,6,7,8,9,10];
var myArray = my20ElementArray.map(Math.random);

You could create an xrange-like function what is in Python but that would just hide this “unused” variable inside a function.

Leave a Comment