
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Difference between == and === operator in JavaScript
In JavaScript, the double and triple equals are used for comparison between two operands. The difference between both the equals is:
Sr. No. | Key | Double Equals (==) | Triple Equals (===) |
---|---|---|---|
1 | Naming | Double equals named as Equality Operator. | Triple equals named as Identity / Strict equality Operator. |
2 | Comparison | Double equals used as Type converting the conversion | Triple equals used as Strict conversion without performing any conversion in operands. |
3 | Syntax | Double equals has syntax for comparison as (a == b) | Triple equals has syntax for comparison as (a === b) |
4 | Implementation | Double equals first convert the operands into the same type and then compare i.e comparison would perform once both the operands are of the same type. This is also known as type coercion comparison. | On the other hand, triple equals do not perform any type of conversion before comparison and return true only if type and value of both operands are exactly the same. |
Example of == vs ===
Equals.jsp
var a = true; var b = 1; var c = true; console.log (a == b); // first convert 1 into boolean true then compare console.log (a === c); // both are of same type no conversion required simple compare. console.log (a === b); // no conversion performed and type of both operands are not of same type so expected result is false.
Output
true true false
- Related Articles
- Difference between != and !== operator in JavaScript Program
- Difference between !== and ==! operator in PHP
- Difference between "new operator" and "operator new" in C++?
- What is the difference between new operator and object() constructor in JavaScript?
- Difference between concat() and + operator in Java
- Difference between == and is operator in python.
- Difference between the and$ operator in php
- Difference between the AND and && operator in php
- Difference between the Ternary operator and Null coalescing operator in php
- Explain difference between == and is operator in Python.
- Difference between the | and || or operator in php
- Difference Between Copy Constructor and Assignment Operator in C++
- Difference between Relational operator(==) and std::string::compare() in C++
- What is the difference between the dot (.) operator and -> in C++?
- What is the difference between equals() method and == operator in java?

Advertisements