OR vs if (v11)

Revision 11 of this benchmark created by Andrew on


Setup

var flag = false
      , i = 1
      , string = 'qwerty'
      , obj = {}
      , zero = 0
      , emptyString = ''
      ;

Test runner

Ready to run.

Testing in
TestOps/sec
OR_i
var result = flag || i;
ready
OR_string
var result = flag || string;
ready
OR_obj
var result = flag || obj;
ready
OR_zero
var result = flag || zero;
ready
OR_emptyString
var result = flag || emptyString;
ready
IF_i
if ( !flag ) {
 var result = i;
}
ready
IF_string
if ( !flag ) {
 var result = string;
}
ready
IF_obj
if ( !flag ) {
 var result = obj;
}
ready
IF_zero
if ( !flag ) {
 var result = zero;
}
ready
IF_emptyString
if ( !flag ) {
 var result = emptyString;
}
ready

Revisions

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