dojo/array foreach

JavaScript performance comparison

Test case created and last updated

Info

Using dojo/array forEach vs lodash each

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js">
</script>
<script>
  require(['dojo/_base/array'], function(array) {
    window.array = array;
  });
</script>
<script>
Benchmark.prototype.setup = function() {
    var _ = window._,
        array = window.array;
   
    var i = 0,
        arr = Array(1000);
   
    for (var k = 0, max = 1000; i < max; i += 1) {
      arr[i] = {
        'name': 'test'
      };
    }
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
dojo each
var results = [];
array.forEach(arr, function(a) {
  results.push(a.name);
});
pending…
lodash each
var results = [];
_.each(arr, function(a) {
  results.push(a.name);
});
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

Add a comment