Skip to content

Instantly share code, notes, and snippets.

@alordiel
Created July 20, 2017 08:44
Show Gist options
  • Save alordiel/a4fa0ee6f3ec0f9c6fed84aa02f47707 to your computer and use it in GitHub Desktop.
Save alordiel/a4fa0ee6f3ec0f9c6fed84aa02f47707 to your computer and use it in GitHub Desktop.
JS types comparing
console.log(null == undefined); // TRUE
console.log(null === undefined); // FALSE
console.log(null == ""); // FALSE
console.log(null == 0); // FALSE
console.log(undefined == ""); // FALSE
console.log(undefined == 0); // FALSE
console.log("" == 0); // TRUE
console.log("" === 0); // FALSE
console.log(false == 0); // TRUE
console.log(false == ""); // TRUE
console.log(false == null); // FALSE
console.log(false == undefined); // FALSE
// Extra cases
console.log("0" == 0); // TRUE
console.log(false == "0"); // TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment