Boolean vs Double Bang

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Double Bang
const student = {
	answer: 'correct'
}

function hasAnswer() {
	return !!student.answer;
}

hasAnswer();
ready
Boolean
const student = {
	answer: 'correct'
}

function hasAnswer() {
	return Boolean(student.answer);
}

hasAnswer();
ready

Revisions

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