# Difference Between == and === in Javascript

### Let's first understand What is == and === in Javascript

The '==' and '===' operators are used to compare if two values are equal

Some Examples of using '==' and '===' operators

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676292637165/46af8c60-1447-49f3-8300-cd0086412dc2.png align="left")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676293012408/10462c0e-79f3-4cc6-973a-42b29c07ce07.png align="left")

## Difference between '==' and '==='

1. The '==' operator is called **loose equality operator**
    

* it compares two values and also does type conversion
    
* When comparing two variables the "==" operator tends to transfer data from one type to another.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676294628060/b9552a4f-66cf-439f-929a-4818fa945ff0.png align="center")
    

1. The '===' operator is called **Strict equality operator**
    

* it will strictly compare the values of both variables and only if they are exactly equal it will return true otherwise it will return false.
    
* the condition for this operator it checks whether both the value and type are equal.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676295922606/7db22e6a-c749-4088-b2ca-38240d21f028.png align="left")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676295890313/8bac8823-8ceb-4aeb-a093-fbf2b2a15fdc.png align="left")
    
    **let's see the difference of using '==' and '==='**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676296381341/58b6cc56-a4bb-478f-98f1-442e66fa84f5.png align="center")
    

**Example of using '==' and '===' with objects**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676303527312/3a494189-4a3a-471f-bb3c-6fd73b243267.png align="center")

* while comparing the objects with '==' and '===' operands it will result in false condition because the reference of the object is different but the properties are same.
    

# conclusion-

* '' == '' will check the type and if they are not the same it will perform a type conversion and then show the result
    
* " === " will check the type, if that matches then will check the value and show the result. if the type is not the same it will result as false.
