_.map function

JavaScript performance comparison

Test case created by Truong Nguyen

Preparation code

<script src="http://underscorejs.org/underscore.js"></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
normal
var arr = [1, 2, 3],
  len = arr.length,
  newArr = [];
for (var i = 0; i < len; i++) {
  newArr.push(newArr.push(arr[i] * arr[i]));
}
pending…
using _
var arr = [1, 2, 3],
  newArr = _.map(arr, function(num) {
    return num * num;
  });
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