---
description: What is = in JavaScript? Equal to (=) is an assignment operator, which sets the variable on the left of the = to the value of the expression that is on its right. This operator assigns lvalue to rvalu
title: Difference Between =, ==, and === in JavaScript [Examples]
---

[Skip to content](#main)

## What is = in JavaScript?

Equal to (=) is an assignment operator, which sets the variable on the left of the = to the value of the expression that is on its right. This operator assigns lvalue to rvalue.

For example, Writing a=10 is fine. If we write 10=10, ‘a’ = 10 or ‘a’ = ‘a’, it will result in a reference error.

## What is == in JavaScript?

Double equals (==) is a comparison operator, which transforms the operands having the same type before comparison.

So, when you compare string with a number, JavaScript converts any string to a number. An empty string is always converts to zero. A string with no numeric value is converts to NaN (Not a Number), which returns false.

## What is === in JavaScript?

=== (Triple equals) is a strict equality comparison operator in JavaScript, which returns false for the values which are not of a similar type. This operator performs type casting for equality. If we compare 2 with “2” using ===, then it will return a false value.

## Why use = in JavaScript?

Here are the important uses of = in [JavaScript](https://www.guru99.com/interactive-javascript-tutorials.html):  

  
= JavaScript operator assigns a value to the left operand depends on the value of operand available on the right side. The first operand should be a variable.

The basic assignment operator is =, that assigns the value of one operand to another. That is, a = b assigns the value of b to a.

## Why use == in JavaScript?

Here are the important uses of == in JavaScript:

The == operator is an equality operator. It checks whether its two operands are the same or not by changing expression from one data type to others. You can use == operator in order to compare the identity of two operands even though, they are not of a similar type.

## How === Works Exactly?

- Strict equality === checks that two values are the same or not.
- Value are not implicitly converted to some other value before comparison.
- If the variable values are of different types, then the values are considered as unequal.
- If the variable are of the same type, are not numeric, and have the same value, they are considered as equal.
- Lastly, If both variable values are numbers, they are considered equal if both are not NaN (Not a Number) and are the same value.

## Example of =

In the below program, there are two variables “a” and “b”. We are adding and printing their values using a third variable, “c”. The sum of the value of variable “a” and “b” is 7. Therefore, the output is 7.

```
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Operators</h2>

 <p>a = 2, b = 5, calculate c = a + b, and display c:</p> 

<p id="demonstration"></p>

<script>
var a = 2;
var b = 5;
var c= a + b;
document.getElementById("demonstration").innerHTML = c;
</script>

</body>
</html>

```

**Don't Miss:**

- [OOJS: Object Oriented JavaScript Tutorial with Example](https://www.guru99.com/learn-object-oriented-javascript.html)
- [10 Best FREE JavaScript IDE & Editor (2026)](https://www.guru99.com/best-javascript-ide.html)
- [Top 50 jQuery Interview Questions and Answers (2026)](https://www.guru99.com/jquery-interview-questions.html)
- [Top 50 Backbone.js Interview Questions and Answers (2026)](https://www.guru99.com/backbone-js-interview-questions.html)

  
**Output:**

a = 2, b = 5, calculate c = a + b, and display c:

7

## Example of ==

In the below program, we have declared one variable “a” having value 10. Lastly, the statement a == 20 returns false as the value of a is 10.

```
<!DOCTYPE html>
<html>
<body>

<p id="demonstration"></p>

<script>
  var a = 10;
  document.getElementById("demonstration").innerHTML = (a == 20);
</script>

</body>
</html>

```

**Output:**

false

## Example of ===

In the below program, the value of variable x is 10. It is compared to 10 written in double-quotes, which is considered as a [string](https://www.guru99.com/javascript-string-format.html), and therefore, the values are not strictly the same. The output of the program is false.

```
<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>

  var x = 10;
  document.getElementById("demo").innerHTML = (x === "10");

</script>

</body>
</html>

```

**Output:**

false

## = Vs == VS === in JavaScript

Here are the important differences between =, ==, and ===  

| = | == | === |
| --- | --- | --- |
| = in JavaScript is used for assigning values to a variable. | == in JavaScript is used for comparing two variables, but it ignores the datatype of variable. | === is used for comparing two variables, but this operator also checks datatype and compares two values. |
| It is called as assignment operator | It is called as comparison operator | It is also called as comparison operator |
| The assignment operator can evaluate to the assigned value | Checks the equality of two operands without considering their type. | Compares equality of two operands with their types. |
| It does not return true or false | Return true if the two operands are equal. It will return false if the two operands are not equal. | It returns true only if both values and data types are the same for the two variables. |
| = simply assign one value of variable to another one. | == make type correction based upon values of [variables](https://www.guru99.com/using-variables-in-javascript.html). | === takes type of variable in consideration. |
| = will not compare the value of variables at all. | The == checks for equality only after doing necessary conversations. | If two variable values are not similar, then === will not perform any conversion. |

## KEY DIFFERENCES

- = is used for assigning values to a variable, == is used for comparing two variables, but it ignores the datatype of variable whereas === is used for comparing two variables, but this operator also checks datatype and compares two values.
- = is called as assignment operator, == is called as comparison operator whereas It is also called as comparison operator.
- = does not return true or false, == Return true only if the two operands are equal while === returns true only if both values and data types are the same for the two variables.

This code is editable. Click Run to Execute  

#### Summarize this post with:

ChatGPTPerplexityGrokGoogle AI

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.**

##### Sign up for the newsletter

Subscribe for Free

You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals

[Scroll to top](#wrapper)

×

Search for:

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/javascript","name":"JavaScript"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html","name":"Difference Between =, ==, and === in JavaScript [Examples]"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#webpage","url":"https://www.guru99.com/difference-equality-strict-operator-javascript.html","name":"Difference Between =, ==, and === in JavaScript [Examples]","dateModified":"2026-10-07T17:59:30+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/editorial","name":"Editorial Team","url":"https://www.guru99.com/author/editorial","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/favicon-new-logo.png","url":"https://www.guru99.com/images/favicon-new-logo.png","caption":"Editorial Team","inLanguage":"en-US"},"sameAs":["https://www.guru99.com/editorial-team"],"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"@type":"NewsArticle","headline":"Difference Between =, ==, and === in JavaScript [Examples]","keywords":"javascript, java","dateModified":"2026-10-07T17:59:30+05:30","articleSection":"JavaScript","author":{"@id":"https://www.guru99.com/author/editorial","name":"Editorial Team"},"publisher":{"@id":"https://www.guru99.com/#organization"},"description":"What is = in JavaScript? Equal to (=) is an assignment operator, which sets the variable on the left of the = to the value of the expression that is on its right. This operator assigns lvalue to rvalu","copyrightYear":"2026","copyrightHolder":{"@id":"https://www.guru99.com/#organization"},"name":"Difference Between =, ==, and === in JavaScript [Examples]","@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#richSnippet","isPartOf":{"@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#webpage"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/difference-equality-strict-operator-javascript.html#webpage"}}]}
```
