explaingit

denysdovhan/wtfjs

Analysis updated 2026-06-20

37,595JavaScriptAudience · developerComplexity · 1/5Setup · easy

TLDR

A collection of surprising JavaScript code examples, each showing something that behaves unexpectedly, with clear explanations of why the language works that way, to help you understand its tricky corners.

Mindmap

mindmap
  root((wtfjs))
    What it does
      Surprising JS examples
      Spec explanations
      Educational humor
    Key topics
      Type coercion
      Floating point
      NaN behavior
      Prototype rules
    Who benefits
      Beginners learning JS
      Interview preppers
      Curious developers
    Format
      Markdown handbook
      npm installable
      Multi-language
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Read through surprising code snippets to understand why JavaScript behaves in ways most people don't expect, like 0.1+0.2 not equaling 0.3.

USE CASE 2

Prepare for technical interviews that test knowledge of JavaScript type coercion, operator precedence, and prototype behavior.

USE CASE 3

Install the npm package and browse the handbook from the command line to study JavaScript quirks at your own pace.

USE CASE 4

Use specific examples and their spec citations as a reference when debugging confusing JavaScript behavior in your own code.

What is it built with?

JavaScriptNode.js

How does it compare?

denysdovhan/wtfjstooljet/tooljetdrawdb-io/drawdb
Stars37,59537,86937,161
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderateeasy
Complexity1/53/51/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Readable directly on GitHub or installable via npm install -g wtfjs to read from the terminal, no setup beyond that.

License information is not mentioned in the explanation.

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
Using the wtfjs examples as a guide, explain why 0.1 + 0.2 does not equal 0.3 in JavaScript and how I should handle decimal math in my code.
Prompt 2
Show me the most surprising JavaScript type coercion examples from wtfjs and explain what rule causes each one.
Prompt 3
Based on the wtfjs NaN behavior examples, write a safe function that checks whether a value is truly a number in JavaScript.
Prompt 4
Walk me through the wtfjs empty array examples, why does [] == ![] evaluate to true in JavaScript?
Prompt 5
Using wtfjs as a reference, generate a 10-question JavaScript quirks quiz I can use to practice for a technical interview.

Frequently asked questions

What is wtfjs?

A collection of surprising JavaScript code examples, each showing something that behaves unexpectedly, with clear explanations of why the language works that way, to help you understand its tricky corners.

What language is wtfjs written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js.

What license does wtfjs use?

License information is not mentioned in the explanation.

How hard is wtfjs to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is wtfjs for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub denysdovhan on gitmyhub

Verify against the repo before relying on details.