jQuery inArray vs Underscore contains

Benchmark created by Tieg on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js">
</script>

Setup

var r;
    var array = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '11', '12', '33', '44', '55', '66', '77', '88', '99'];

Test runner

Ready to run.

Testing in
TestOps/sec
$.inArray
r = $.inArray('33', array);
ready
_.contains
r = _.contains(array, '33');
ready

Revisions

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