equal vs not

Benchmark created by happyWang on


Description

check a string is contained in another string.

use String.prototype.indexOf method

return -1 if not contains.

Setup

var str = 'this is a string for test',
        test = 'that';

Test runner

Ready to run.

Testing in
TestOps/sec
equal
if (str.indexOf(test) === -1){
    // do something
}
ready
not
if (~(str.indexOf(test)){
    // do something
}
ready

Revisions

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

  • Revision 1: published by happyWang on