i++ vs ++i vs i += 1 vs i = i + 1

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
i++
for (let i = 0; i < 1000000000; ) {
  i++;
}
ready
++i
for (let i = 0; i < 1000000000; ) {
  ++i;
}
ready
i += 1
for (let i = 0; i < 1000000000; ) {
  i += 1;
}
ready
i = i + 1
for (let i = 0; i < 1000000000; ) {
  i = i + 1;
}
ready

Revisions

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