Compare string vs. boolean (v2)

Revision 2 of this benchmark created on


Description

Is comparing a string quicker or slower than comparing a boolean?

Setup

var sA = 'ben';
    var sB = 'fox';
    var sResult = '';
    var bA = true;
    var bB = false;
    var bResult = false;

Test runner

Ready to run.

Testing in
TestOps/sec
Compare var to string
if (sA === 'ben') {
  sResult = 'success';
}
ready
Compare var to boolean
if (bA === false) {
  bResult = true;
}
ready
Compare var to var (string)
if (sA === sB) {
  sResult = 'success';
}
ready
Compare var to var (boolean)
if (bA === bB) {
  bResult = true;
}
ready

Revisions

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