multiple strings comparison VS array includes

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
multiple strings
const req = {method : "GET"}
if (req.method !== "GET") {
// do something
}
ready
array includes GET
const req = {method : "GET"}
const allowedMethods = ["GET", "HEAD"]
if (allowedMethods.includes[req.method]) {
	// do something
}
ready
array includes HEAD
const req = {method : "HEAD"}
const allowedMethods = ["GET", "HEAD"]
if (allowedMethods.includes[req.method]) {
	// do something
}
ready

Revisions

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