Conversion from boolean to number (v7)

Revision 7 of this benchmark created on


Setup

var boolValue = true;

Test runner

Ready to run.

Testing in
TestOps/sec
Ternary operator
boolValue ? 1 : 0
ready
Unary + operator
+boolValue
ready
Number function
Number(boolValue)
ready
Unary & operator
boolValue & 1
ready
Ternary operator with type
boolValue === true ? 1 : 0
ready

Revisions

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