fastest way to find a vowel in a string

Benchmark created on


Description

Setup

var str = "XlKdmHBJcVyZLoqiMwTNjPRYFsgbACthQWuOxDZlaeEjvIUKMprYSwnXTGcfboARHdqVJzmBLWpNMEysuKCgi
"

Test runner

Ready to run.

Testing in
TestOps/sec
forEach loop in
const forEach = () => {
	str.split("").forEach((s) => {
		if(s in "aeiouAEIOU") return true;
	});
	return false;
}
ready
forEach loop equals
const forEach = () => {
	str.split("").forEach((s) => {
		const t = s.toLowerCase();
		if(t == 'a' || t == 'e' || t == 'i' || t == 'o' || t == 'u') return true;
	});
	return false;
}
ready
forEach loop map equals
const forEach = () => {
	str.split("").map((s) => s.toLowerCase())forEach((s) => {

		if(s == 'a' ||s  == 'e' || s == 'i' || s == 'o' || s == 'u') return true;
	});
	return false;
}
ready

Revisions

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