O'Reilly logo

Beautiful JavaScript by Anton Kovalyov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER FIFTEEN

Progress

This is a risky chapter to write—it’s possible that some of the code it contains will be wrong by the time this book goes to print. In June 2015 the sixth edition of the ECMAScript standard is scheduled to be published, which means that by the time you’re reading it, this chapter is either a goldmine or a dud. While being rational certainly has its merits, being adventurous and perhaps a little irrational is also valuable, so here we go.

To be clear: I really love JavaScript—as a general-purpose programming language, it is a truly unique and beautiful creation. When I say beautiful, I don’t necessarily mean it in the classical sense: sometimes a beast can also be beautiful—that beast just needs someone to love it and dress it in nice clothes for the ball.

JavaScript has an easy-to-use mechanism for inheritance.

No one

If I had a nickel for every mention of “JavaScript inheritance” on the Internet-according-to-Google, at the time of this writing I would have over $2,000.1 The top results2 all disagree with each other, but in interesting and not-incorrect ways. The problem is that JavaScript’s built-in mechanism for defining a class of object and its behavior is the same mechanism used for defining any encapsulated operation: a function. Additionally, veterans of other programming languages like C++, C#, Java, Python, Ruby, and so on tend to get hung up on JavaScript’s lack of inheritance as they understand it in those languages. JavaScript’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required