Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Created March 30, 2011 07:19
Show Gist options
  • Save ahmadajmi/893998 to your computer and use it in GitHub Desktop.
Save ahmadajmi/893998 to your computer and use it in GitHub Desktop.
Boolean
var foo = NaN; // NaN is false value
Boolean(foo); // return false
!!NaN; // return false
!NaN; // return true
var foo = "i love javascript"; // string is true value but empty string "" is false value
Boolean(foo); // return true
!!foo; // return true
!foo; // convert the value to boolean and negates it // return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment