Parsing booleans

Benchmark created on


Description

Parsing boolean variables from string

Setup

var booleanAsString = 'tRuE';

Test runner

Ready to run.

Testing in
TestOps/sec
Simple comparison
const booleanAsBoolean = booleanAsString.toLowerCase() === 'true';
ready
Simple comparison, as a function
function stringToBoolean(str){
  return str.toLowerCase() === 'true';
}
ready
JSON.parse
const booleanAsBoolean = JSON.parse(booleanAsString.toLowerCase())
ready

Revisions

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