Logo

dev-resources.site

for different kinds of informations.

“==” and “===” difference in javascript

Published at
6/30/2024
Categories
javascript
webdev
beginners
Author
sagar
Categories
3 categories in total
javascript
open
webdev
open
beginners
open
“==” and “===” difference in javascript

In javascript both “==” and “===” used for comparison but they have purposes and behaviors

== (Double equal)

:
The == operator is used for loose equality comparison . When we compare with == it will only compare values not the data type means if we compare string of “5” and integer 5 the result will be true

console.log(5=="5") //  true
console.log(5==5) //  true

2. === (triple equal):

The === operator is used for strict equality comparison. As we studied == only compare values not data type but === compare both values and datatype means if we compare string of “5” and integer 5 the result will be false both values and data type must same

console.log(5=="5") //  false
console.log(5==5) //  true

Featured ones: