Open In App

Strict Equality(===) Comparison Operator in JavaScript

Last Updated : 23 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

JavaScript Strict Equality Operator is used to compare two operands and return true if both the value and type of operands are the same. Since type conversion is not done, so even if the value stored in operands is the same but their type is different the operation will return false. 

Syntax:

a===b

Example 1: In this example, we will compare the value of the same data types.

Javascript




let a = 2, b=2, c=3;
let d = {name:"Ram"};
let e = {name:"Ram"};
let f = e;
  
console.log(a===b);
console.log(a===c);
console.log(d===e);
console.log(f===e);


Output: Just like other comparisons when two objects are compared their reference is checked and true is only returned if the reference is the same.

true
false
false
true

Example 2: In this example, we will use the strict equality operator on different data types.

Javascript




let a = 2;
let b= "2";
let c = true;
let d = null;
let e = undefined;
  
console.log(a===b);
console.log(a===c);
console.log(d===e);


Output: Even though some values are the same but still false is returned as the data type is different.

false
false
false

Supported Browsers:

  • Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

We have a complete list of JavaScript Comparison Operators, to check those please go through, the JavaScript Comparison Operator article


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads