Chapter 9: Objects

Objects are abstract data types used in programming. They can be used to represent real-world objects such as people, animals or places, as well as more abstract concepts such as bank account details, dates or file structures.

In some languages, such as Ruby, practically everything is an object. There are no primitive values, just objects. Even the number zero is an object. A large number of languages, such as Java, are class-based languages. These involve creating classes that act as a blueprint for creating all the objects in that class. For example, a Car class might specify that all Car objects will have an engine, four wheels and a choice of color.

JavaScript is not a class-based language (although you can define classes ...

Get Learn to Code With JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.