Cover page by Christian Johansen

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 7. Objects and Prototypal Inheritance

JavaScript is an object oriented programming language. However, unlike most other object oriented languages, JavaScript does not have classes. Instead, JavaScript offers prototypes and prototype-based inheritance in which objects inherit from other objects. Additionally, the language offers constructors—functions that create objects, a fact that often confuses programmers and hides its nature. In this chapter we’ll investigate how JavaScript objects and properties work. We’ll also study the prototype chain as well as inheritance, working through several examples in a test-driven manner.

7.1 Objects and Properties

JavaScript has object literals, i.e., objects can be typed directly into a program ...

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