String reversion by split then reverse and joining vs concatenation

Benchmark created on


Description

Tests two known string reversing methods.

  1. Reverse the string using array, by doing string.split("").reverse().join("").

  2. Reverse the string with a naive concatenation method.

Test runner

Ready to run.

Testing in
TestOps/sec
String split reverse join
let data = "A quick brown fox jumps over the lazy dog.";
let output = data.split("").reverse().join("");
ready
String concatenation
let data = "A quick brown fox jumps over the lazy dog.";
let output = '';
for (let i = data.length; --i >= 0; ) {
	output += data[i];
}
ready

Revisions

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