Skip to Content
Head First JavaScript Programming
book

Head First JavaScript Programming

by Eric T. Freeman, Elisabeth Robson
March 2014
Beginner
704 pages
18h 25m
English
O'Reilly Media, Inc.
Content preview from Head First JavaScript Programming

Chapter 13. Extra strength objects

Using Prototypes

image with no caption

Learning how to create objects was just the beginning. It’s time to put some muscle on our objects. We need more ways to create relationships between objects and to share code among them. And, we need ways to extend and enhance existing objects. In other words, we need more tools. In this chapter, you’re going to see that JavaScript has a very powerful object model, but one that is a bit different than the status quo object-oriented language. Rather than the typical class-based object-oriented system, JavaScript instead opts for a more powerful prototype model, where objects can inherit and extend the behavior of other objects. What is that good for? You’ll see soon enough. Let’s get started...

image with no caption

If you’re used to Java, C++, or any language based on classical object-oriented programming let’s have a quick chat.

And if you aren’t... what, you got a date? Take a seat, and go along for the ride—you might just learn something as well.

We’ll give it to you straight: JavaScript doesn’t have a classical object-oriented model, where you create objects from classes. In fact, JavaScript doesn’t have classes at all. In JavaScript, objects inherit behavior from other objects, which we call prototypal inheritance, or inheritance based on prototypes. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First JavaScript Programming, 2nd Edition

Head First JavaScript Programming, 2nd Edition

Eric Freeman, Elisabeth Robson
Head First HTML and CSS, 2nd Edition

Head First HTML and CSS, 2nd Edition

Elisabeth Robson, Eric Freeman
JavaScript from Beginner to Professional

JavaScript from Beginner to Professional

Rob Percival, Laurence Svekis, Maaike van Putten, Codestars By Rob Percival

Publisher Resources

ISBN: 9781449340124Errata PageSupplemental Content