String Join and Concatenation Performance Comparison

Benchmark created on


Setup

const values = [...Array(1000).keys()].map(e => e.toString())

Test runner

Ready to run.

Testing in
TestOps/sec
String joining using join() method
let concatenatedString = values.join(', ')
console.log(concatenatedString)
ready
String concatenation using +
let concatenatedString = ''
for (let index = 0; index < values.length; index++) {
        concatenatedString += ', ' + values[index];
}
console.log(concatenatedString)
ready

Revisions

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