Swastik Yadav


Navigate back to the homepage

JavaScript Loose Equality vs Strict Equality check

Swastik Yadav
June 4th, 2021 · 1 min read

Hello Everyone!

In this post we will explore the difference between JS loose equality (==) and strict equality (===) check.

Here is the simplest definition

  • Loose equality (==) checks for value only.
  • Strict equality (===) checks for value as well as DataType.

But wait, there is something more to it. Let’s understand the workings of both of them one by one.

Strict Equality (===)

Strict equality first checks for DataType, If datatype is same then it checks for value, else it returns false.


1console.log("55" === 55);
2// false - Because datatype is different even though value is same.


Loose Equality (==)

Loose equality works similar to strict equality. The only difference is that in loose equality if datatype is different, it performs an Implicit type conversion and then compares the value.


1console.log("55" == 55);
2// true - Because implicit conversion will change string "55" to number 55 then compare value.


If you enjoyed or found this post helpful, please consider joining my weekly Newsletter below.

Thank You!

More articles from Swastik Yadav

Toggle functionality with pure CSS and no JavaScript

Create a compelete menu / sidebar toggle functionality with pure CSS and no JavaScript

May 31st, 2021 · 1 min read

How CSS is parsed on the browser

How CSS is parsed on the browser?, How CSS render the document style?, How layout of the page is decided?

May 28th, 2021 · 1 min read

Become a better full-stack developer in 10 minutes a week.

Be the first to receive our latest content with the ability to opt-out at anytime. We promise to not spam your inbox or share your email with any third parties.

By subscribing, you agree with Revue’s Terms and Privacy Policy.
© 2021 Swastik Yadav
Link to $https://twitter.com/swastikJsDevLink to $https://github.com/SwastikyadavLink to $https://www.linkedin.com/in/swastik-yadav-6386b71b5/Link to $https://www.youtube.com/channel/UCHs73qDeimVFGTa-MzjtnLA