denysdovhan /wtfjs

🤪 A list of funny and tricky JavaScript examples

★ 37,693⑂ 2,673👁 564⑃ 202● 123▤ 25
JavaScriptWTFPLCreated 2017-07-14bit.ly/wtfjavascript
下载:v1.22.8v1.22.8 ↓1.22.82022-09-30
+0
日增长
+6
周增长
37,693
stars
2,673
forks
564
watchers
202
prs
123
issues
25
releases

README

What the f\ck JavaScript?

[![WTFPL 2.0][license-image]][license-url]
[![NPM version][npm-image]][npm-url]
[![Patreon][patreon-image]][patreon-url]
[![Buy Me A Coffee][bmc-image]][bmc-url]

 A list of funny and tricky JavaScript examples

JavaScript is a great language. It has a simple syntax, large ecosystem and, what is most important, a great community.

At the same time, we all know that JavaScript is quite a funny language with tricky parts. Some of them can quickly turn our everyday job into hell, and some of them can make us laugh out loud.

The original idea for WTFJS belongs to Brian Leroux. This list is highly inspired by his talk “WTFJS” at dotJS 2012:



 Node Packaged Manuscript

You can install this handbook using npm. Just run:


$ npm install -g wtfjs


You should be able to run wtfjs at the command line now. This will open the manual in your selected $PAGER. Otherwise, you may continue reading on here.

The source is available here: 

 Translations

Currently, there are these translations of wtfjs:

- 中文
- हिंदी
- Français
- Português do Brasil
- Polski
- Italiano
- 한국어

[Help translating to your language][tr-request]

[tr-request]: https://github.com/denysdovhan/wtfjs/blob/master/CONTRIBUTING.mdtranslations

Note: Translations are maintained by their translators. They may not contain every example, and existing examples may be outdated.




 Table of Contents

- 💪🏻 Motivation
- ✍🏻 Notation
- 👀 Examples
  - [[] is equal ![]](-is-equal-)
  - [true is not equal ![], but not equal [] too](true-is-not-equal--but-not-equal--too)
  - true is false
  - baNaNa
  - NaN is not a NaN
  - Object.is() and === weird cases
  - It's a fail
  - [[] is truthy, but not true](-is-truthy-but-not-true)
  - null is falsy, but not false
  - document.all is an object, but it is undefined
  - Minimal value is greater than zero
  - function is not a function
  - Adding arrays
  - Trailing commas in array
  - Array equality is a monster
  - undefined and Number
  - parseInt is a bad guy
  - Math with true and false
  - HTML comments are valid in JavaScript
  - NaN is ~~not~~ a number
  - [[] and null are objects](-and-null-are-objects)
  - Magically increasing numbers
  - Precision of 0.1 + 0.2
  - Patching numbers
  - Comparison of three numbers
  - Funny math
  - Addition of RegExps
  - Strings aren't instances of String
  - Calling functions with backticks
  - Call call call
  - A constructor property
  - Object as a key of object's property
  - Accessing prototypes with __proto__
  -  ${{Object}} 
  - Destructuring with default values
  - Dots and spreading
  - Labels
  - Nested labels
  - Insidious try..catch
  - Is this multiple inheritance?
  - A generator which yields itself
  - A class of class
  - Non-coercible objects
  - Tricky arrow functions
  - Arrow functions can not be a constructor
  - arguments and arrow functions
  - Tricky return
  - Chaining assignments on object
  - Accessing object properties with arrays
  - Number.toFixed() display 

Top issues

Discussions

Latest release

v1.22.8 v1.22.8 2022-09-30
1.22.8 (2022-09-30)


 Bug Fixes

 broken link in zh-cn translation (278) (c6f8310)

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON