The difference between Double equal(==) and triple equal(===) too in javascript
Difference between == and ===
Table of contents
No headings in the article.
When we want to compare something in JavaScript we use == or ===. but there is major difference between between == and ===.
==> == Only compare the value of both variable whereas === compare the value and type of the variable.
just as:-
var a = 1;
var b = "1";
console.log(a == b);
// output = true
here a
and b
contains the value same (1), that's why output comes true
.
var a = 1;
var b = "1";
console.log(a === b);
//output = false
here a
and b
contains the same value (1) but a
has data types of number
whereas b
has datatypes of string that's why it gives the output false
because ===
compare value and data types of variable