Exceptions for validation errors vs typical logic

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Exception
const validateInput = () => {
	throw Error('Fail');
}

try {
	validateInput();
} catch {
	console.log('failed');
}
ready
No exception
const validateInput = () => {
	return false;
}

if (!validateInput()) {
	console.log('failed');
}
ready

Revisions

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