find vs indexof

Benchmark created by Leo on


Setup

'use strict';
    
    var board = [['red', 'red', 'red'], ['red', 'red', 'red'], ['red', 'green', 'red']];

Test runner

Ready to run.

Testing in
TestOps/sec
find
board.find(function (row) {
  return row.find(function (cell) {
    return cell === 'green' && console.log('found a green cell') && true;
  });
}) || false;
ready
indexof
board.toString().indexOf("green") > -1
ready

Revisions

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