If you've used a more traditional object-oriented language, such as C++ or Java, JavaScript probably doesn't seem object-oriented at all. It has no concept of classes, and you don't even need to define any objects in order to write code. But don't be fooled—JavaScript is an incredibly powerful and expressive object-oriented language that puts many design decisions right into your hands.

The Principles of Object-Oriented JavaScript will leave even experienced developers with a deeper understanding of JavaScript. Unlock the secrets behind how objects work in JavaScript so you can write clearer, more flexible, and more efficient code.

Author Bio

Nicholas C. Zakas is a software engineer at Box and is known for writing on and speaking about the latest in JavaScript best practices. He honed his experience during his five years at Yahoo!, where he was principal front­end engineer for the Yahoo! home page. He is the author of several books, including Maintainable JavaScript (O’Reilly Media, 2012) and Professional JavaScript for Web Developers (Wrox, 2012).

"A reference I will keep with me throughout my JavaScript career, and I'll recommend it to any developer interested in JavaScript."
—Cory Gackenheimer, author of Node.js Recipes (Read More)

"An exciting foray into JavaScript. Not only did it shed light on some long-existing features that I had never fully considered... it also helped bring me up-to-date on how the JavaScript language is evolving"
—Ben Nadel, CTO at InVision App, Inc (Read More)

Page 7:
In Figure 1-3, the bottom-lefthand box should say object2, not object1. Please see the following image for the correct figure:

Page 24:
The last sentence on this page should read: "You can then call the method directly from the object as in person.sayName()."

Page 25:
In the second code listing on this page, var name = "Michael"; should be this.name = "Michael";.

Page 26:
The very first sentence on this page should read: "In this example, a function called sayNameForAll is defined first."

Page 26:
The second paragraph should read: "The last part of this example defines a global property called name. When sayNameForAll() is called directly, it outputs "Michael" because this is equivalent to the global object."

Page 33:
In Figure 3-1, [[Put]]name, [[Put]]age, and [[Set]]name should have spaces, like so: [[Put]] name, [[Put]] age, and [[Set]] name

Page 38:
The last two lines of the code at the top of this page should be:person1.name = "Greg"; // "Setting name to Greg"
console.log(person1.name); // "Reading name" then "Greg"

Page 68:
The last line of the last example reads

// "[Object Window]true"
but it should instead read

// "[Object Window]5"

Page 86:
The fifth line of the last example should be:this.fire({ type: "namesaid", name: this.name });

Page 87:
In the ninth line of the first example, this.fire({ type: "namesaid", name: name }); should be this.fire({ type: "namesaid", name: this.name });

In the second example, new EventTarget() should be EventTarget.prototype, and the first sentence of the paragraph that follows should read: Here, Person.prototype is mixed in with EventTarget.prototype (1) to get the event behavior.

In the eleventh line of the second example, this.fire({ type: "namesaid", name: name }); should be this.fire({ type: "namesaid", name: this.name });

Page 88:
In the seventh line of the first example, this.fire({ type: "namesaid", name: name }); should be this.fire({ type: "namesaid", name: this.name });

In the ninth line of the second example, this.fire({ type: "namesaid", name: name }); should be this.fire({ type: "namesaid", name: this.name });

Page 89:
In the seventeenth line of this example, this.fire({ type: "namesaid", name: name }); should be this.fire({ type: "namesaid", name: this.name });