Understanding Prototypal Inheritance within JavaScript

InstructorTyler Clark

Share this video with your friends

Send Tweet

Unlike classical languages like C# and Java, JavaScript does not have a true class. It utilizes linking objects together in order to inherit properties. Every single object that you create, unless specified not to, is automatically linked to the corresponding global object prototype.

We also have the ability through utility functions and other methods to link objects together to share functionality. This lesson walks through a simple implementation of this inheritance paradigm and attempts to show how prototypes are used.

Robin
~ 5 years ago

Why do people call proto the "dunder" prototype? I tried to google this, but I could not find anything useful.

Ed
~ 5 years ago

My guess is "dunder" is short for "double underscore." So "dunder proto" would be a quick way to say "proto" instead of "double underscore proto double underscore."

Will Johnson
~ 5 years ago

@Ed is correct!

Viktor Soroka
~ 5 years ago

Just for clarity,

The next-in-line prototype object through the Dunder property is the global object prototype object that all objects are given when no prototype is specified or mutated otherwise.

Could you please explain what 'mutated otherwise' part means? I have the idea that this is about the case when another object (Object.create, the inheritance of classes) is assigned as Dunder proto rather than given by default when no prototype is specified.

Tyler Clarkinstructor
~ 5 years ago

Could you please explain what 'mutated otherwise' part means?

This is how you could mutate that next prototype:

const a = {}

a.__proto__ = {}
~ 3 years ago

Now looks very different, now appear [[prototype]] with methods, and inside the dunder proto.. why?