DEV Community

Cover image for What the f#$k is strict equality.
Eduardo Henao
Eduardo Henao

Posted on

What the f#$k is strict equality.

Sometimes I see some memes regarding Javascript equality and yeah, some of them are pretty funny, here is my favorite.

Image description

I see that there is a common pattern, this "weird" behavior always happens with the double equal sign operator == which we can call loose equality. This happens because it perfoms the IsLooselyEqual algorithm, and the Javascript engine will perform a typer cohertion to try to match both sides in type and value.

How can avoid these "weird" behavior?

Well when you use the triple equal operator === javascript doesn't convert at all the type of your values, and then performs a comparison and checks that both values and types, and if both are for example the same number and the same type, the result of the comparison will be 'true'.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

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

Okay