Under the Hood: Objects and Prototypes

Learn how JavaScript classes are different from classes in other programming languages.

If you come from another programming background, chances are you already encountered classes and feel familiar with them. But as you’ll soon discover, JavaScript classes are not quite like their C++, Java, or C# counterparts.

JavaScript’s object-oriented model

To create relationships between objects, JavaScript uses prototypes.

In addition to its own particular properties, any JavaScript object has an internal property which is a link (known as a reference) to another object called its prototype.

When trying to access a property that does not exist in an object, JavaScript tries to find this property in the prototype of this object. Here’s an example (borrowed from Kyle Simpson’s great book series You Don’t Know JSlink).

Get hands-on with 1400+ tech skills courses.