greater than or not equal

JavaScript performance comparison

Test case created by magikMaker

Info

Test to find out whether it's faster to test against '!= -1' or against '>= 0' when using indexOf on a String.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var search = 'find the cat',
        string = 'How fast can we find the cat';
};
</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
equals -1
var test = string.indexOf(search) != -1
pending…
greater than
var test = string.indexOf(search) >= 0
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