for VS forEach

Benchmark created by Develoger on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>

Setup

var year = [];
  for (var i = 0; i < 365; i++) {
    year.push(i);
  };
    
  function getDate(day) {
    return moment().day(day).format('l');
  };

Test runner

Ready to run.

Testing in
TestOps/sec
for
for (var i = 0; i < year.length; i++) {
  getDate(year[i]);
};
ready
forEach
year.forEach(function(day) {
  getDate(day);
});
ready

Revisions

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

  • Revision 1: published by Develoger on