.map: Underscore.js versus jQuery versus LoDash (v5)

Revision 5 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript" type="text/javascript">
window.jQuery = $.noConflict()
</script>
<script src="https://zeptojs.com/zepto.min.js"></script>
<script src="https://underscorejs.org/underscore-min.js"></script>
<script language="javascript" type="text/javascript">
window.underscore = _.noConflict();
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.compat.js"></script>
<script language="javascript" type="text/javascript">
window.lodash = _.noConflict();
</script>

Setup

var vals = new Array(999)
    for(var i = 0; i < vals.length; i++){vals[i] = i}

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
jQuery.map(vals, function (i, x) { return i*x })
ready
Underscore.js
underscore.map(vals, function (x, i) { return x*i })
ready
Lo-Dash
lodash.map(vals, function (x, i) { return x*i })
ready
Native
vals.map(function (x, i) { return x*i })
ready
Zepto
Zepto.map(vals, function (i, x) { return i*x })
ready
Loop
var result = new Array(vals.length);
for (var i = 0; i < vals.length; i++) {
result[i] = i * vals[i];
}
ready

Revisions

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