So… Hacker News went down for about a day. I lost my main source of procrastination (reddit contained all purple links). So what did I do? I got productive. I wrote about 20% of a book on Javascript.
You should register your interest for Underhanded Javascript, Or: How to be a Complete Arsehole with Bad Javascript (there’s an alternate title that I’m considering: Javascript Technical Interview Questions).
Here’s a quick blurb of the book:
Javascript is a weird and wonderful language. However. there are often more warts though, and they often remain unexplained. If anything, Javascript does not follow the principle of least surprise. If you have ever seen WTF-worthy Javascript code (and any Javascript dev would have seen at least one), this book is for you. If you were surpised with the result of a particular piece of code, and wondered why the results are what they are, this book is for you. If you have ever wondered why [0] == 0
? Why "true" == true
returns false
then this book is for you.
In this book I go through ~15 examples of crazy Javascript that would make anyone go “WTF??!”, examples such as:
- Why certain Immediately Invoked Function Expressions don’t work?
- Why in some contexts, commas act funnily.
- Why in some cases newlines act funnily.
- Why in some cases, Google Chrome appears to support block-level scoping without ES6 syntax
- Why truthy values are not true, and why falsey values are not false
-
What is
foo)(
- And many more
I go through these examples, and in a tongue-in-cheek manner, suggest ways to wreak havoc on the unsuspecting. I for one do not actually condone such behaviour. However, all the examples in this book, I have actually seen in real life, and have often cursed the arsehole developers who wrote them. The actual main aim of this book is to help write better code by showing the obvious pitfalls that you may find when debugging other peoples’ codes.
This book assumes you are already an intermediate-to-advanced frontend or backend Javascript developer, and is considered to be light reading. Early reviews have compared it to a light-hearted Programmng Pearls for Javascript developers. This author thinks it’s more like Programming Turds, but okay.
I expect to finish this book by 24th January 2014. Preview copies will be out on 25th, and it will go on sale February 1.
Update
The name of the book has changed to Underhanded Javascript. It was formerly called Javascript Oddities. The subtitle of the book remains the same.