Convert Array to Set, Object, Map

Benchmark created on


Setup

var theArr = Array.from({ length: 10 }, (_, el) => el);

Test runner

Ready to run.

Testing in
TestOps/sec
Create Set
mySet = new Set(theArr);
ready
Create Object
var theObject = Object.assign({}, ...theArr.map(num => ({ [num]: true })))
ready
Create Map
var theMap = new Map(theArr.map(num => [num, true]))
ready

Revisions

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