<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh" -->

---
title: Most JavaScript Developers Get == Wrong in Interviews...
description: JavaScript's loose equality operator `==` follows deterministic type coercion rules from the ECMAScript spec, not random behavior. Three core rules govern all...
canonical: https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Most JavaScript Developers Get == Wrong in Interviews (Not Because It's Hard) | daily.dev
og:description: JavaScript's loose equality operator `==` follows deterministic type coercion rules from the ECMAScript spec, not random behavior. Three core rules govern all...
og:url: https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh
og:image: https://api.daily.dev/og/posts/I6IheuZwH.png
og:image:alt: Most JavaScript Developers Get == Wrong in Interviews (Not Because It's Hard)
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.

# Most JavaScript Developers Get == Wrong in Interviews (Not Because It's Hard)

**[Medium](https://daily.dev/sources/medium_js)** · 5 min read · 1 upvotes · 0 comments

## Summary

JavaScript's loose equality operator `==` follows deterministic type coercion rules from the ECMAScript spec, not random behavior. Three core rules govern all comparisons: Booleans convert to Numbers, Strings convert to Numbers when compared with Numbers, and Objects convert to primitives via Symbol.toPrimitive → valueOf() → toString(). Applying these rules step-by-step explains classic interview puzzles like `[] == false`, `[null] == 0`, and `[] == ![]` without memorization.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@dheeraj.bartwal91/most-javascript-developers-get-wrong-in-interviews-not-because-its-hard-729901790e2d>

## Questions this post answers

### Why does [] == false evaluate to true in JavaScript?

False converts to the number 0 under the Boolean-to-Number rule. The empty array then converts to a primitive via toString(), producing an empty string, which converts to 0 under the String-to-Number rule. The comparison becomes 0 == 0, which is true.

_Developers debugging loose equality quirks like this one can dig deeper into JavaScript coercion rules on daily.dev._

### Why does [null] == 0 return true in JavaScript?

Converting the array [null] to a string via toString() produces an empty string, because null and undefined are rendered as empty strings when arrays are joined. That empty string then converts to the number 0 under the String-to-Number rule, making the comparison 0 == 0, which evaluates to true.

_Anyone puzzling over odd array equality results can explore more JavaScript coercion edge cases on daily.dev._

### What is the object-to-primitive conversion order JavaScript uses for == comparisons?

JavaScript first tries Symbol.toPrimitive, then falls back to valueOf(), and finally to toString(). Arrays typically end up using toString(), which is why array-to-primitive comparisons like [] == false or [null] == 0 often resolve through string conversion rather than valueOf().

_Developers working through JavaScript's coercion internals can find more breakdowns like this on daily.dev._

## Similar posts on daily.dev

- [JavaScript Interview Preparation Challenge : Day 2](https://daily.dev/posts/javascript-interview-preparation-challenge-day-2-y9pndxttk) · Medium · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#interview-questions](https://daily.dev/tags/interview-questions)

[View this post on daily.dev](https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh)

```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":"TechArticle","headline":"Most JavaScript Developers Get == Wrong in Interviews (Not Because It's Hard)","url":"https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh"},"datePublished":"2026-07-22T06:07:49.695Z","dateModified":"2026-09-14T07:38:27.717Z","description":"JavaScript's loose equality operator `==` follows deterministic type coercion rules from the ECMAScript spec, not random behavior. Three core rules govern all...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,interview-questions","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Most JavaScript Developers Get == Wrong in Interviews (Not Because It's Hard)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/most-javascript-developers-get-wrong-in-interviews-not-because-it-s-hard--i6iheuzwh#faq","mainEntity":[{"@type":"Question","name":"Why does [] == false evaluate to true in JavaScript?","acceptedAnswer":{"@type":"Answer","text":"False converts to the number 0 under the Boolean-to-Number rule. The empty array then converts to a primitive via toString(), producing an empty string, which converts to 0 under the String-to-Number rule. The comparison becomes 0 == 0, which is true. Developers debugging loose equality quirks like this one can dig deeper into JavaScript coercion rules on daily.dev."}},{"@type":"Question","name":"Why does [null] == 0 return true in JavaScript?","acceptedAnswer":{"@type":"Answer","text":"Converting the array [null] to a string via toString() produces an empty string, because null and undefined are rendered as empty strings when arrays are joined. That empty string then converts to the number 0 under the String-to-Number rule, making the comparison 0 == 0, which evaluates to true. Anyone puzzling over odd array equality results can explore more JavaScript coercion edge cases on daily.dev."}},{"@type":"Question","name":"What is the object-to-primitive conversion order JavaScript uses for == comparisons?","acceptedAnswer":{"@type":"Answer","text":"JavaScript first tries Symbol.toPrimitive, then falls back to valueOf(), and finally to toString(). Arrays typically end up using toString(), which is why array-to-primitive comparisons like [] == false or [null] == 0 often resolve through string conversion rather than valueOf(). Developers working through JavaScript's coercion internals can find more breakdowns like this on daily.dev."}}]}
```

