explaingit

denysdovhan/wtfjs

37,600JavaScriptAudience · developerComplexity · 1/5StaleLicenseSetup · easy

TLDR

A curated collection of surprising JavaScript quirks with explanations of why the language behaves that way, from floating-point weirdness to type coercion surprises.

Mindmap

mindmap
  root((repo))
    What it does
      Showcases quirks
      Explains why
      Cites spec rules
    Examples
      Type coercion
      Operator precedence
      Floating point
      Prototype rules
    Use cases
      Learn internals
      Interview prep
      Understand gotchas
    Format
      Code snippet
      Explanation
      Spec reference
    Distribution
      npm package
      Markdown docs
      Multiple languages

Things people build with this

USE CASE 1

Deepen your understanding of JavaScript's type system and how the language evaluates code.

USE CASE 2

Prepare for technical interviews by learning the quirks and edge cases interviewers probe.

USE CASE 3

Debug unexpected behavior in your own code by recognizing common JavaScript gotchas.

Tech stack

JavaScriptNode.jsnpmMarkdown

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

WTF JavaScript is a curated collection of surprising, counter-intuitive, and sometimes hilarious JavaScript code examples, each one accompanied by an explanation of why the language behaves that way. The problem it solves is not a technical one but an educational one: JavaScript has many quirks baked into its specification that confuse beginners and catch even experienced developers off guard. Rather than pretending these quirks don't exist, this project shines a light on them. Each entry follows a simple format: a short snippet of valid JavaScript that produces a result most people would not expect, followed by an Explanation section that walks through the relevant specification rules. Examples range from the famous floating-point imprecision (0.1 + 0.2 not equaling 0.3) to stranger behaviors like an empty array being equal to the negation of an empty array, NaN not being equal to itself, and Math.max() returning a value smaller than Math.min() when called with no arguments. The explanations cite the JavaScript specification (ECMAScript) and walk through type coercion, operator precedence, and prototype rules, core language mechanics that are easy to misunderstand. You would use this repository when you want to deepen your understanding of JavaScript's type system and evaluation rules, prepare for technical interviews that probe language internals, or simply enjoy the humor of a language that occasionally feels like it was designed to trick you. The handbook is installable as an npm package (so you can read it from the command line), translated into multiple languages, and organized with a table of contents for easy browsing. The tech stack is minimal: it is essentially a Markdown document distributed as a Node.js npm package, written in JavaScript for its examples. No runtime framework or build system is involved.

Copy-paste prompts

Prompt 1
Show me why 0.1 + 0.2 doesn't equal 0.3 in JavaScript and how to work around it.
Prompt 2
Explain the JavaScript quirks from wtfjs that would trip up a junior developer in a code review.
Prompt 3
Give me 5 surprising JavaScript behaviors from wtfjs and explain the ECMAScript spec rules behind each one.
Prompt 4
How would I use wtfjs to prepare for a JavaScript technical interview focused on language internals?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.