Beautiful JavaScript

This is an excerpt from Beautiful JavaScript, a book edited by Anton Kovalyov and published by O’Reilly.

Functions are first-class citizens, syntax resembles Java, inheritance is prototypal, and (+””) equals zero. This is JavaScript, arguably the most polarizing and misunderstood programming language in the world. It was created in 10 days and had a lot of warts and rough edges. Since then, there have been many attempts to replace it as the language of the Web. And yet, the language and the ecosystem around it are thriving. JavaScript is the most popular language in the world — and the only true language of the web platform. What made JavaScript special? Why did a language that was created in such a hurry succeed where others failed?

I believe the reasons why JavaScript (and the Web in general) survived lie in its omnipresence — it’s practically impossible to find a personal computer that doesn’t have some sort of JavaScript interpreter — and its ability to gain from disorder, to use its stressors for self-improvement.

JavaScript, like no other language, brought all kinds of different people to the platform. Anyone with a text editor and a web browser could get started with JavaScript, and many did. Its expressiveness and limited standard library prompted those people to experiment with the language and push it to its limits. People were not only making websites and applications; they were writing libraries and creating programming languages that could be compiled back into JavaScript. Those libraries competed with each other, and their approaches to solving problems often contradicted one another. The JavaScript ecosystem was a mess, but it was bursting with life.

Many of those libraries and languages are now forgotten. Their best ideas, however — the ones that proved themselves and stood the test of time — were absorbed into the language. They made their way into JavaScript’s standard library and its syntax. They made the language better.

Then there were languages and technologies that were designed to replace JavaScript. But instead of succeeding, they unwillingly became its necessary stressors. Every time a new language or system to replace JavaScript emerged, browser vendors would find a way to make it faster, more powerful, and more robust. Once again, good ideas were absorbed into newer versions of the language, and the bad ones were discarded. These competing technologies didn’t replace JavaScript; instead, they made it better.

Today, JavaScript is unbelievably popular. Will it last? I don’t know. I cannot predict whether it will still be popular 5 or 10 years from now, but it doesn’t really matter. For me, JavaScript will always be a great example of a language that survived not despite its flaws but because of them, and a language that brought people of so many different backgrounds into this wonderful world of computer programming.


This book was written by people who are intimately familiar with the language. Each and every person who contributed a chapter is an expert in his or her domain. The authors highlight different sides of JavaScript, some of which you can discover only by writing lots of code, experimenting and making mistakes. As you make your way through this book, you’ll get to see what JavaScript movers and shakers love about their favorite language.

You’ll also learn a lot. I did. But do not mistake this book for a JavaScript tutorial, because it is much bigger than that. There are chapters that challenge the conventional wisdom and show how even the most feared features can be used as helpful tools. Some authors show that JavaScript can be a tool for self-expression and a form of art, while others share the wisdom of using JavaScript in codebases with hundreds of contributors. Some authors share personal stories, while others look into the future.

There’s no common pattern that goes from one chapter to another — there’s even a purely satirical chapter. This is intentional. I tried to give the authors as much freedom as possible to see what they would come up with, and they came up with something incredible. They came up with a book that resembles JavaScript itself, where each chapter is a reflection of its author.

Contributors include: Angus Croll, Jonathan Barronville, Sara Chipps, Marijn Haverbeke, Ariya Hidayat, Daryl Koopersmith, Anton Kovalyov, Rebecca Murphey, Daniel Pupius, Graeme Roberts, Jenn Schiffer, Jacob Thornton, Ben Vinegar, Rick Waldron, and Nicholas Zakas.

You can buy Beautiful JavaScript from O’Reilly or Amazon. All author royalties will be donated to EFF (Electronic Frontier Foundation).

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.