Strict Equality or Identity Operators in JavaScript


In JavaScript, identity operators are used to compare the equality of two values while also considering their data types. There are two identity operators:

  • Strict Equality Operator (===)
    • The strict equality operator (===) checks for equality between two values while considering both their values and data types. It returns true if both the values and data types are identical, and false otherwise
  • Equality Operator (==)
    • The equality operator (==) also checks for equality between two values, but it performs type coercion if the data types are different. It tries to convert one or both operands to the same type before making the comparison.

Source Code

HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Tutor Joes</title>
</head>
<body>
 
	<script src="js/script.js"></script>
</body>
</html>
To download raw file Click Here

script.js
//strict equality or Identity Operator

let a=10;
console.log(a);
let b='10';
console.log(a==b);
console.log(a===b);
To download raw file Click Here

List of Programs


JS Practical Questions & Answers


JS Practical Project