_.first() vs [0] (v2)

Revision 2 of this benchmark created by antic on


Description

lodash .first() vs. built-in [0]

Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>

Setup

var myArray = [];
    
    for(var i=0; i<1000000; i++) {
        myArray.push(i);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Underscore
console.log(_(myArray).first());
ready
Native
console.log(myArray[0]);
ready

Revisions

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