contains comparisons

Benchmark created by luke on


Description

Boolean(Array.indexOf() > -1) vs. Boolean(Array.indexOf() != -1) vs. Boolean(Array.indexOf()++)

Setup

var array = [];
    for (var i=0; i<10; i++) {
      array.push(i);
    }
    function test() {
      return array.indexOf(9);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
less than
Boolean(test() > -1);
ready
plus one
Boolean(function(){var a=test();return ++a;})
ready
not equal
Boolean(test() != -1);
ready

Revisions

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