Boolean() vs !!

JavaScript performance comparison

Test case created

Info

Testing which is faster in various situations: Boolean(expr)

or

!! expr

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Boolean - Window
Boolean(window)
pending…
Boolean - True
Boolean(true)
pending…
Boolean - Number
Boolean(1)
pending…
Boolean - Function
function sup(){
 return true;
}
Boolean(sup())
pending…
dbl neg - window
!! window
pending…
dbl neg - true
!! true
pending…
dbl neg - num
!! 1
pending…
dbl neg - function
function sup(){
 return true;
}
!! sup()
pending…
dbl neg - window (w/ brackets)
!!(window)
pending…
dbl neg - num (w/ brackets)
!!(1)
pending…
dbl neg - true (w/ brackets)
!!(true)
pending…
dbl neg - func (w/ brackets)
function sup(){
 return true;
}
!!(sup())
pending…

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

Compare results of other browsers

0 comments

Add a comment