The JavaScript blog.


javascript humour


Posted on .

wtfjs is a blog of JavaScript's irregularities, inconstancies and unintuitive aspects. The author posts humorous code
snippets which are similar to the bad parts from Crockford's
JavaScript: The Good Parts.

Other than the obvious examples based around the confusing nature of
falsy and NaN, there are some interesting examples that might test your knowledge of JavaScript:

("foo" + + "bar") === "fooNaN"
(x=[].reverse)() === window // true

Am I suffering from a kind of blindness due to writing JavaScript for
too long, or does the following make sense?

"string" instanceof String; // false
(new String("string")) instanceof String; // true

Of course it's false, it's a string literal rather than an instance of
String! Is it useful to distinguish between string literals and
instances of String?