Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created January 20, 2023 12:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save shameemreza/2558c7a59913ade57e249a548274a188 to your computer and use it in GitHub Desktop.
Strict and Loose Equality Example in JavaScript
// Use strict equality when comparing variables of the same type
let age = 25;
let legalAge = 21;
console.log(age === legalAge); // false
// Use loose equality when comparing variables that may be a string or a number
let input = "25";
let number = 25;
console.log(input == number); // true
// Use loose equality when comparing a variable to null or undefined
let name;
console.log(name == undefined); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment