Skip to content
DevMeme
2156 of 7590
Languages Post #2407 · source on Telegram

JavaScript's Identity Crisis: NaN is a Number

Description

A meme featuring a frantic-looking man with glasses (Joji as Filthy Frank) with his hands up in a gesture of chaos. The top text reads, 'When you do typeof on a NaN in javascript'. The bottom text is a modified version of the 'Shit just went from zero to one hundred real quick' meme, saying 'Shit just went from NaN to one Number real fucking quick.' The words 'NaN' and 'Number' are highlighted to emphasize the punchline. The meme humorously captures one of the most famous and counter-intuitive quirks in JavaScript: the fact that the special value `NaN` (Not-a-Number) has a `typeof` that returns 'number'. For seasoned developers, this is a classic 'gotcha' that has likely caused debugging headaches at some point in their careers, making the absurdity of the situation highly relatable

Comments

10
Anonymous ★ Top Pick In JavaScript, NaN is the spy who came in from the cold. It insists it's a number, but it's not equal to itself, poisons every calculation it touches, and its only reliable identifier is `isNaN()`. Trust nothing
  1. Anonymous ★ Top Pick

    In JavaScript, NaN is the spy who came in from the cold. It insists it's a number, but it's not equal to itself, poisons every calculation it touches, and its only reliable identifier is `isNaN()`. Trust nothing

  2. Anonymous

    typeof NaN === 'number' - the day you realise JavaScript’s type system is as binding as a story-point estimate, and suddenly “migrate to TypeScript” and “budget for therapy” end up in the same sprint

  3. Anonymous

    After 20 years in this industry, I've accepted that JavaScript's typeof NaN === 'number' makes perfect sense - it's the one honest thing about JavaScript, admitting that even its numbers aren't really numbers

  4. Anonymous

    Ah yes, JavaScript's typeof NaN === 'number' - because nothing says 'robust type system' quite like a value that literally means 'Not a Number' being classified as a number. It's the programming equivalent of a restaurant sign saying 'No Food Served Here' while still being categorized as a dining establishment. This IEEE 754 legacy quirk has been gaslighting developers since the '90s, making isNaN() the most passive-aggressive function in the standard library. At least TypeScript's strict null checks can't save you from this one - some wounds run deeper than static analysis

  5. Anonymous

    typeof NaN === 'number': JS's polite way of telling NaN, 'You're a number now, act like it - until equality checks expose the fraud.'

  6. Anonymous

    In JS, typeof NaN === "number" and NaN !== NaN - evidence that IEEE-754 and web‑compat outvote intuition; just use Number.isNaN() and keep the SLA

  7. Anonymous

    typeof NaN === 'number'; NaN !== NaN; Object.is(NaN, NaN) === true - JavaScript’s polite way of reminding you IEEE‑754 runs this town

  8. @NiKryukov 5y

    So, NaN is a number?

  9. @ryankrage77 5y

    number's NaN

  10. @Flam_Su 5y

    NaN is a variant of float. Aswell as INF

Use J and K for navigation