Skip to Content
Speaking JavaScript
book

Speaking JavaScript

by Axel Rauschmayer
February 2014
Beginner to intermediate content levelBeginner to intermediate
460 pages
8h 32m
English
O'Reilly Media, Inc.
Content preview from Speaking JavaScript

Chapter 17. Objects and Inheritance

There are several layers to object-oriented programming (OOP) in JavaScript:

Each new layer only depends on prior ones, enabling you to learn JavaScript OOP incrementally. Layers 1 and 2 form a simple core that you can refer back to whenever you are getting confused by the more complicated layers 3 and 4.

Layer 1: Single Objects

Roughly, all objects in JavaScript are maps (dictionaries) from strings to values. A (key, value) entry in an object is called a property. The key of a property is always a text string. The value of a property can be any JavaScript value, including a function. Methods are properties whose values are functions.

Kinds of Properties

There are three kinds of properties:

Properties (or named data properties)
Normal properties in an object—that is, mappings from string keys to values. Named data properties include methods. This is by far the most common kind of property.
Accessors (or named accessor properties)
Special methods whose invocations look like reading ...
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

The Joy of JavaScript

The Joy of JavaScript

Luis Atencio
Secrets of the JavaScript Ninja, Second Edition

Secrets of the JavaScript Ninja, Second Edition

Bear Bibeault, Josip Maras, John Resig

Publisher Resources

ISBN: 9781449365028Errata