Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Developer Reading List

, February 25, 2014 Java 8, JavaScript, Functional Programming, and Software Engineering
  • E-mail
  • Print

The Principles of Object-Oriented JavaScript

by Nicholas Zakas

JavaScript is sufficiently like most other mainstream languages, and yet just different enough to frustrate and tantalize most programmers who are forced to use it (so, just about everyone today). This frustration is most readily apparent in the growth of languages that compile to JavaScript, but use an improved syntax (CoffeeScript, Typescript, and Dart, for example). And the frustration most acutely strikes developers who are accustomed to object orientation — they get to use objects, but not classes; local variables, but not private ones; and so on.

This very short (fewer than 100 pages) work explains to the OO developer in simple, readable prose how exactly objects work in JavaScript and what to expect. The author, who previously wrote the well-regarded Maintainable JavaScript, digs into the implementation of various language features to show how JavaScript implements a given feature under the hood. (For example, a function is merely any object with an internal property named Call.) From there, he demonstrates what is and is not possible to do and how best to approximate OO concepts from other languages. He does expect readers to be familiar with OO concepts and to have at least basic knowledge of JavaScript. For this, he rewards you with remarkably readable explanations, along with code snippets to illustrate the mechanics of JavaScript implementation and how to create ersatz object orientation for the missing features.

I think The Principles of Object-Oriented JavaScript is an excellent second book for new JavaScript developers (after one of the tutorials listed here), as it will save the curious from many hours spent on Q&A forums asking how to do X or Y that they're familiar with in other languages. My only complaint — a minor one — is that the book feels premature in a sense. The new ECMAScript 6 standard, which defines JavaScript, should be finalized in June and approved December. It will contain many new OO features, including classes and modules, which will make much of this discussion out-of-date, especially since the major browsers are likely to implement those features right away. Other than this one quibble, the book is a delightful, informative read and, with a street price of less than $20, an easy recommendation.

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.