for loop vs fun

JavaScript performance comparison

Test case created by tenthirtyone

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function forLoop(arr) {
  for (let i = 0; i < arr.length; i++) {
  console.log(arr[i])
  }}
  
  function funLoop(arr) {
  arr.forEach(item => console.log(item))
  }

};
</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 loop
const arr = [0,1,2,3,4,5,6,7,8,9]

forLoop(arr)
pending…
functional
const arr = [0,1,2,3,4,5,6,7,8,9]

funLoop(arr)
pending…

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

Compare results of other browsers

0 Comments