indexOf vs includes

Benchmark created on


Description

Comparison of string.indexOf against string.includes

Preparation HTML

<html>
</html>

Setup

let phrase = "The moment the man devours the fruit of knowledge, he sealed his fate, entrusting his future to the cards. The man clings on a dim hope.";

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
let result = phrase.indexOf("hope");
console.log(result);
ready
includes
let result = phrase.includes("hope");
console.log(result);
ready

Revisions

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