Array.indexOf vs Array.includes (v2)

Revision 2 of this benchmark created on


Setup

var arr = [];
for(var i =0; i<10000;i++) arr.push((Math.random()).toString(36));
arr.push('findMe');

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
arr.indexOf('findMe')
ready
includes
arr.includes('findMe')
ready
indexOf > -1
arr.indexOf('findMe') > -1
ready
includes === true
arr.includes('findMe') === true
ready
indexOf !== -1
arr.indexOf('findMe') !== -1
ready
~indexOf
~arr.indexOf('findMe')
ready
indexOf === -1
arr.indexOf('findMe') === -1
ready

Revisions

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