Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 10:32
Show Gist options
  • Save iamsaief/ee4ba8b4442f679c6fd93c8b7db45cce to your computer and use it in GitHub Desktop.
Save iamsaief/ee4ba8b4442f679c6fd93c8b7db45cce to your computer and use it in GitHub Desktop.
/* 👎 double equal == */
const first = 1;
const second = "1";
if (first == second) {
console.log(true, `${first} == ${second}`);
} else {
console.log(false, `${first} != ${second}`);
}
// Output : true 1 == 1
/* 👍triple equal === */
const first = 1;
const second = "1";
if (first === second) {
console.log(true, `${first} == ${second}`);
} else {
console.log(false, `${first} != ${second}`);
}
// Output : false 1 != 1
/* 🤔 implicit type conversion, double equal == */
const first = 1;
const second = true;
if (first == second) {
console.log(true, `${first} == ${second}`);
} else {
console.log(false, `${first} != ${second}`);
}
// Output : true 1 == true 😮
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment