About this project

# What the f*ck JavaScript? This repository is a collection of humorous and puzzling JavaScript examples, inspired by Brian Leroux's talk "WTFJS" at dotJS 2012. It aims to gather crazy code snippets and explain how they work, often referencing the ECMA-262 specification. The handbook is available as an npm package (`wtfjs`) for offline reading, and has been translated into multiple languages including Chinese, Hindi, French, Portuguese, Polish, Italian, and Korean. ## Content Overview The list includes over 60 examples, each with a code snippet and a detailed explanation. Topics cover: - **Equality and coercion quirks**: e.g., `[] == ![]` is `true`, `true == []` is `false`, `null == false` is `false`. - **NaN and number oddities**: `NaN === NaN` is `false`, `Number.MIN_VALUE > 0` is `true`, `parseInt` edge cases. - **Array and string behaviors**: array concatenation, trailing commas, array equality monsters. - **Function and class anomalies**: `class Foo extends null` errors, arrow functions not being constructors. - **Miscellaneous tricks**: `"b" + "a" + +"a" + "a"` results in `'baNaNa'`, HTML comments in JavaScript, `document.all` being undefined, and more. Each example is annotated with links to relevant sections of the ECMA-262 specification or external references, making it a useful reference for both beginners seeking deeper understanding and professionals looking for a compendium of JavaScript's unexpected edges. ## Motivation The primary goal is fun and learning. The author encourages readers to explore the specification and discover something new, whether they are beginners or experienced developers. ## Usage Install via npm: ``` $ npm install -g wtfjs ``` Then run `wtfjs` to open the manual in your preferred pager. ## Translations Community-maintained translations are available for several languages, though they may not include every example or be fully up to date. ## License Released under the WTFPL 2.0 license.