Skip to content

Instantly share code, notes, and snippets.

@maxcnunes
Created October 8, 2014 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcnunes/b8129feec4195e7425f0 to your computer and use it in GitHub Desktop.
Save maxcnunes/b8129feec4195e7425f0 to your computer and use it in GitHub Desktop.
Javascript Double Not-Operator(!!)
if (typeof x !=== 'undefined' && x !=== '') {
// not emtpy
}
if (x) {
// not emtpy
}
var xIsEmpty = !!x;
var x = 0; // falsy
console.log(!x); // true (it is not what we want)
console.log(!!x); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment