ES5 Array methods

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var _ = window._;
    var array = Array(100);
    for (var index = 0; index < 100; index++) {
      array[index] = index;
    }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Array#forEach
var result = Array(100);
array.forEach(function(value, index) {
  result[index] = value * value;
});
pending…
_.forEach
var result = Array(100);
_.forEach(array, function(value, index) {
  result[index] = value * value;
});
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. Here’s a list of current revisions for this page:

0 comments

Add a comment