Created
March 13, 2017 23:25
-
-
Save brettinternet/435cd81bf1df62e69d2ea2d9638f32b0 to your computer and use it in GitHub Desktop.
!!expression operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!!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