Cover by John Resig and Bear Bibeault

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

O'Reilly logo

Chapter 6. Object-orientation with prototypes

In this chapter we discuss

  • Using functions as constructors
  • Exploring prototypes
  • Extending objects with prototypes
  • Avoiding common gotchas
  • Building classes with inheritance

Now that we’ve learned how functions are first-class objects in JavaScript, and how closures make them incredibly versatile and useful, we’re ready to tackle another important aspect of functions: function prototypes.

Those already somewhat familiar with JavaScript prototypes might think of them as being closely related to objects, but once again it’s all about functions. Prototypes are a convenient way to define types of objects, but they’re actually a feature of functions.

Prototypes are used throughout JavaScript as ...

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