Join a Set

Benchmark created on


Description

spread to array then join vs manually concat strings

Setup

set = new Set(['a', 'b', 'c'])

Test runner

Ready to run.

Testing in
TestOps/sec
spread to array then join
[...set].join(', ')
ready
manually concat strings
let result = ''
let i = 0

for (const value of set) {
	result += i++ === 0 ? value : ', ' + value
}

result
ready

Revisions

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