JavaScript Equality and Strict Equality

المعرفة:: JavaScript,
الحالة:: ملاحظة_مؤرشفة
المراجع:: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality, The Complete JavaScript Course 2022 From Zero to Expert


  • The (loose) equality operator (==) checks whether its two operands are equal, returning a Boolean result. It attempts to convert and compare operands that are of different types.
  • The strict equality operator (===) checks whether its two operands are equal, returning a Boolean result. Unlike the equality operator, the strict equality operator always considers operands of different types to be different.
18 == 18; // true  
18 == 19; // false  
18 == "18"; // true  
18 === 18; // true  
18 === 19; // false  
18 === "18"; // false  

Last update : August 14, 2023
Created : August 23, 2022

Comments

Comments