DEV Community

Cover image for “==” and “===” difference in javascript
sagar
sagar

Posted on

“==” 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay