DEV Community

loading...

Discussion on: Don’t pay the for-loop tax

Collapse
waiyaki profile image
James Muturi

A little late to the discussion, but generating the array declaratively would probably go a little faster if we make Array think it's converting an "array-like" structure and provide a map function.

console.time("Array.from");
var array = Array.from({length: 1e7}, (_, i) => i);
console.timeEnd("Array.from");