Here I am going to explain to you what is the difference between == and === in Javascript. This is mostly asked Interview Question.

Difference Between == and === in Javascript:

JavaScript has the support of both Strict equality and type-converting equality.

  • Strict Equality (===): Strict Equality means the values which have to compare must have the same type. This means:
           3==="3"  //returns false
  • Type-Converting Equality(==): Which convert the values to the same type before performing the comparison.
           3=="3" //returns true

Difference Between == and ===


<title>Difference between == and === in javascript</title>
<script type="text/javascript">
function Diff() {
var value= "3";
if (value == 3)
document.write("== Returns true <br/>")
document.write("== Returns false <br/>")
if (value === 3)
document.write("=== Returns true <br/>")
document.write("=== Returns false <br/>")
<input type="button" id="btncheck" onclick="Diff()" value="Check Difference" />

View Demo

View More:


I hope you understand this tutorial. You can comment for any technical question. Your suggestions and feedback are welcome.

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in C:\inetpub\vhosts\\httpdocs\wp-includes\wp-db.php on line 3353