Array Mapping

Benchmark published by System on

Description

Array.map vs Array.from for transforming data.

Setup

const arr = Array.from({length: 1000}, (_, i) => i);

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Array.map
const res = arr.map(x => x * 2);
ready
Array.from
const res = Array.from(arr, x => x * 2);
ready
for loop
const res = new Array(arr.length);
for(let i=0; i<arr.length; i++) res[i] = arr[i] * 2;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

Revision 1
publishedby Systemon