What is the Difference Between =, ==, and === in JavaScript

What is the Difference Between =, ==, and === in JavaScript

What is = in JavaScript? 

Equivalent to (=) is a task administrator, which sets the variable on the left of the = to the worth of the articulation that is to its right side. This administrator doles out lvalue to rvalue. 

For instance, Writing a=10 is fine. In the event that we compose 10=10, 'a' = 10 or 'a' = 'a', it will bring about a reference blunder. 

What is == in JavaScript? 

Twofold equivalents (==) is an examination administrator, which changes the operands having a similar kind before correlation. 

Thus, when you contrast string and a number, JavaScript changes any string over to a number. An unfilled string is consistently converts to nothing. A string with no numeric worth is converts to NaN (Not a Number), which returns bogus. 

What is === in JavaScript? 

=== (Triple equivalents) is a severe fairness examination administrator in JavaScript, which returns bogus for the qualities which are not of a comparative kind. This administrator performs type projecting for uniformity. On the off chance that we contrast 2 and "2" utilizing ===, it's anything but a bogus worth. 

Why use = in JavaScript? 

Here are the significant employments of = in JavaScript: 

= JavaScript administrator relegates a worth to one side operand relies upon the worth of operand accessible on the right side. The principal operand ought to be a variable. 

The fundamental task administrator is =, that doles out the worth of one operand to another. That is, a = b doles out the worth of b to a. 

Why use == in JavaScript? 

Here are the significant employments of == in JavaScript: 

The == administrator is a correspondence administrator. It checks if its two operands are something very similar by changing articulation from one information type to other people. You can utilize == administrator to think about the personality of two operands despite the fact that, they are not of a comparable sort. 

How === Works Exactly? 

  • Severe equity === watches that two qualities are something very similar or not. 
  • Worth are not certainly changed over to some other worth before correlation. 
  • Assuming the variable qualities are of various kinds, the qualities are considered as inconsistent. 
  • On the off chance that the variable are of a similar sort, are not numeric, and have a similar worth, they are considered as equivalent. 
  • In conclusion, If both variable qualities are numbers, they are viewed as equivalent if both are not NaN (Not a Number) and are a similar worth. 

Example of = 

In the underneath program, there are two factors "a" and "b". We are adding and printing their qualities utilizing a third factor, "c". The amount of the worth of variable "a" and "b" is 7. Thusly, the yield is 7.

<!DOCTYPE html>

<h2>JavaScript Operators</h2>

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

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

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


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>

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

  var a = 10;
  document.getElementById("demonstration").innerHTML = (a == 20);


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, and therefore, the values are not strictly the same. The output of the program is false.

<!DOCTYPE html>

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


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




  • = 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.

Author Biography.


CrowdforThink is the leading Indian media platform, known for its end-to-end coverage of the Indian startups through news, reports, technology and inspiring stories of startup founders, entrepreneurs, investors, influencers and analysis of the startup eco-system, mobile app developers and more dedicated to promote the startup ecosystem.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforJobs is an advanced hiring platform based on artificial intelligence, enabling recruiters to hire top talent effortlessly.


CrowdforApps brings to you the well researched list of the most successful and finest App development companies, Web software developers.


CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.


CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.


News & Blogs


An In-Depth Guide On Choosing Best Frontend Fra...

Since the outbreak of COVID-19, business operations have been moved online to make ends meet....


JavaScript Mobile Frameworks worth considering ...

When it comes to startups entering the business arena, they have very tough competition. This is ...


How to Generate a PDF with JavaScript

An extremely regular use case today is that of enabling your clients to download information from...

Top Authors

Lamia Rochdi is the Marketing Manager at Bell Flavors & Fragrances EMEA. A successful family-...

Lamia Rochdi

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

I’m Mertin Wilson a technician in a camera company and certified expert of different P...

Mertin Wilson

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working i...

Lokesh Gupta

Our Client Says

WhatsApp Chat with Our Support Team