DEV Community

Cover image for The difference between lose equality and strict quality in Javascript
1

The difference between lose equality and strict quality in Javascript

In JavaScript, the qual value operator (==) is used to check whether a variable is equal to a value or not. Example
let p = "20";
if (p ==20){
alert("yes");
}
Looking at this code, p is actually qual to 20.
But if the if statement is like this
if (p === 20) it won't alert yes why?
Because, our strict equality or qual type and qual value operator also checks whether the values are of the same data types or not. Our "20" is a number string but what we passed in our logic is just a number.

Strict equality is really helpful, it helps you to avoid unnecessary bugs in your Codes. You can use lose quality but you have to be care on the data types.

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

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay