I want to create 10 Fly
objects in a functional manner. I thought this would work:
var flies = new Array(10).map(function() {
return new Fly();
});
It doesn't. It creates an array of length ten with undefined
as their values.
How can I create 10 objects without using for(var i = 0; i < 10; i++)...
?
EDIT: This is an academic exercise for the sake of learning only. It's find if a for
is used under the hood. I'm just trying to figure out what JavaScript can do.