join vs tostring vs stringify vs for

Benchmark created on


Setup

const
	target1 = 'a'.repeat(100).split(''),
	target2 = 'a'.repeat(100).split('');

Test runner

Ready to run.

Testing in
TestOps/sec
join
target1.join('') === target2.join('');
ready
tostring
target1.toString() === target2.toString()
ready
stringify
JSON.stringify(target1) === JSON.stringify(target2);
ready
for
const { length } = target1;
for(let i = 0; i < length; i++) {
	if(target1[i] !== target2[i]) {
		break;
	}
}
ready

Revisions

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