---
title: "What is the difference between \"==\" and \"===\" in JavaScript?"  
description: "What is the difference between \"==\" and \"===\" in JavaScript?"  
author: "Revati S Misra"  
published: 2023-05-15  
updated: 2023-05-15  
canonical: https://www.mindstick.com/forum/158323/what-is-the-difference-between-and-in-javascript  
category: "javascript"  
tags: ["javascript", "javascript object"]  
reading_time: 2 minutes  

---

# What is the difference between "==" and "===" in JavaScript?

What is the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between "==" and "===" in [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)?

## Replies

### Reply by Aryan Kumar

The difference between "==" and "===" in JavaScript is that "==" is a loose equality operator, while "===" is a strict equality operator.

- **==**

The == operator performs a loose equality comparison that performs type coercion if necessary to make the comparison possible. This means that it will return true if the two operands are equal, even if they are of different types. For example, the following code will return true:

Code snippet

```plaintext
var a = 1;
var b = "1";

console.log(a == b); // true
```

This is because the == operator will convert the string "1" to the number 1 before comparing it to the variable a.

- **===**

The === operator performs a strict equality comparison that does not perform type coercion. This means that it will only return true if the two operands are equal and of the same type. For example, the following code will return false:

Code snippet

```plaintext
var a = 1;
var b = "1";

console.log(a === b); // false
```

This is because the === operator will not convert the string "1" to the number 1 before comparing it to the variable a.

In general, you should use === whenever possible. It is more reliable and will prevent unexpected results. You should only use == if you need to support older browsers that do not support ===.


---

Original Source: https://www.mindstick.com/forum/158323/what-is-the-difference-between-and-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
