<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj" -->

---
title: JavaScript Equality: == vs === Explained | daily.dev
description: A lighthearted look at JavaScript's equality quirks, covering the difference between == (loose equality with type coercion) and === (strict equality), plus...
canonical: https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: JavaScript Equality: == vs === Explained | daily.dev
og:description: A lighthearted look at JavaScript's equality quirks, covering the difference between == (loose equality with type coercion) and === (strict equality), plus...
og:url: https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj
og:image: https://api.daily.dev/og/posts/XdXsQaulJ.png
og:image:alt: JavaScript Equality: == vs === Explained
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript Equality: == vs === Explained

**[Al-Hussein Abubakar](https://daily.dev/sources/w4cpliwixqqftnip2vq9e)** · [@aldrake](https://daily.dev/aldrake) · 2 min read · 0 upvotes · 1 comments

## Summary

A lighthearted look at JavaScript's equality quirks, covering the difference between == (loose equality with type coercion) and === (strict equality), plus edge cases like NaN === NaN returning false, typeof null being 'object', and [] == ![] being true. Also touches on Object.is() for handling -0 vs +0 comparisons.

## Content

I swear, JavaScript equality is out here trying to gaslight me.

Today, I had a value that printed as 0 in the console… but my if (value == 0) check was somehow skipping.

Turns out, it was “0” from some form field.
== said “yeah, same same”, I said “nah fam, not today”.

Then my brain went back to the classics that still hurt:
NaN === NaN → false (who hurt you, NaN?)
typeof null → “object” (bro, we’ve been carrying this L since before I was born)
and the one that made me close VS Code for 10 minutes: [] ==![] → true 😭
I eventually wrote the post I needed when I was losing my mind over this stuff years ago:
why == is basically playing matchmaker with types,
Why most of us just live on === now,
the one sneaky situation where loose equality is actually cleaner,
and why [**Object.is**](http://Object.is)() exists for the people who actually care about -0 vs +0 (not me… yet).

If JS equality has ever made you want to throw your laptop into the Gulf of Guinea, tell me your worst one below.
Misery loves company.

I have sat down to write a breakdown with the cursed examples if you want: [https://blog.al-husayn.dev/blog/equality-operators](https://blog.al-husayn.dev/blog/equality-operators)
Dropping the link in comments if you’re ready to hate JavaScript a little more today

## Community discussion

Top comments from developers on daily.dev.

**@aldrake** · 0 upvotes

> [https://blog.al-husayn.dev/blog/equality-operators](https://blog.al-husayn.dev/blog/equality-operators)

## Similar posts on daily.dev

- [Most JavaScript Developers Get == Wrong in Interviews \(Not Because It's Hard\)](https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh) · Medium · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj","headline":"JavaScript Equality: == vs === Explained","text":"A lighthearted look at JavaScript's equality quirks, covering the difference between == (loose equality with type coercion) and === (strict equality), plus edge cases like NaN === NaN returning false, typeof null being 'object', and [] == ![] being true. Also touches on Object.is() for handling -0 vs +0 comparisons.","url":"https://daily.dev/posts/javascript-equality-vs-explained-xdxsqaulj","datePublished":"2026-03-12T07:20:16.690Z","dateModified":"2026-03-12T07:20:33.033Z","author":{"@type":"Person","name":"Al-Hussein Abubakar","url":"https://daily.dev/aldrake","image":"https://lh3.googleusercontent.com/a/ACg8ocJWWqQxgPldbrnkxbq1uGAcS5wmI-VvIh12Yp01g-rY6iiLztsw=s96-c","description":"Software Developer ","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":60}},"image":"https://media.daily.dev/image/upload/s--FpT3uPQf--/f_auto/v1773300016/posts/XdXsQaulJ?_a=BAMAMiiu0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"comment":[{"@type":"Comment","text":"https://blog.al-husayn.dev/blog/equality-operators","datePublished":"2026-03-12T07:21:49.494Z","url":"https://daily.dev/posts/XdXsQaulJ#c-BDAcuXDeN","author":{"@type":"Person","name":"Al-Hussein Abubakar","url":"https://daily.dev/aldrake","image":"https://lh3.googleusercontent.com/a/ACg8ocJWWqQxgPldbrnkxbq1uGAcS5wmI-VvIh12Yp01g-rY6iiLztsw=s96-c"}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/w4cpliwixqqftnip2vq9e","name":"Al-Hussein Abubakar"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Al-Hussein Abubakar","item":"https://daily.dev/sources/w4cpliwixqqftnip2vq9e"},{"@type":"ListItem","position":3,"name":"JavaScript Equality: == vs === Explained"}]}
```

