Skip to content

Instantly share code, notes, and snippets.

@brettinternet
Created March 13, 2017 23:25
Show Gist options
  • Save brettinternet/435cd81bf1df62e69d2ea2d9638f32b0 to your computer and use it in GitHub Desktop.
Save brettinternet/435cd81bf1df62e69d2ea2d9638f32b0 to your computer and use it in GitHub Desktop.
!!expression operator
!!false === false
!!true === true
!!0 === false
!!parseInt("foo") === false // NaN is falsy
!!1 === true
!!-1 === true // -1 is truthy
!!"" === false // empty string is falsy
!!"foo" === true // non-empty string is truthy
!!"false" === true // ...even if it contains a falsy value
!!window.foo === false // undefined is falsy
!!null === false // null is falsy
!!{} === true // an (empty) object is truthy
!![] === true // an (empty) array is truthy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment