for...each...of

JavaScript performance comparison

Test case created by medns

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const a = [];
  for (let i = 0; i < 1_000_000; i += 1) {
    a.push(i);
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
for...each
var x = 0;
a.forEach((i) => {
  x = i
})
pending…
for
var x = 0
for (let i = 0; i < a.length; i += 1) {
  x = a[i]
}
pending…
for...of
var x = 0;
for (const k of a) {
  x = k
}
pending…

Compare results of other browsers

Revisions

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

0 Comments