Plus Equals New vs Equals Old Plus New

Benchmark created by scunliffe on


Description

I've always used

foo += bar;

for string concatenation but I'm curious how it performs against

foo = foo + bar;

at high volume.

Test runner

Ready to run.

Testing in
TestOps/sec
A Plus Equals B
var a = 'hello';
for (var b = 0; b < 25000; b++) {
 a += b;
}
ready
A Equals A plus B
var a = 'hello';
for (var b = 0; b < 25000; b++) {
 a = a + b;
}
ready

Revisions

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