AngularJS/Lodash(underscore) foreach (v32)

Revision 32 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js">
</script>
<script src="https://rawgit.com/lodash/lodash/2.4.1/dist/lodash.js">
</script>

Setup

var _ = window._;
    var angular = window.angular;
    var arr = Array(1e3);
    for (var i = 0; i < 1e3; i++) {
      arr[i] = i;
    }
    
    var sum = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
AngularJS
angular.forEach(arr, function(i) {
  sum += i;
});
ready
Lodash
_.forEach(arr, function(i) {
  sum += i;
});
ready
Native
arr.forEach(function(i) {
  sum += i;
});
ready
For
for (var i = 0; i < arr.length; i++) {
  if (arr.hasOwnProperty(i)) {
    sum += arr[i];
  }
}
ready

Revisions

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