0:37 Let's break down what's happening here. I created an empty object and assigned it to the variable a. When I console.log this a, just to see what it looks like, we see that it's got a property on it called proto.
0:51 Its value pair is another object that's been automatically added to this key, and it has a whole bunch of properties on it.
0:59 This proto key is also called Dunder proto. As I say Dunder proto from here on out, I'm referencing this automatically-created property, proto.
1:29 Let's dive a little deeper into prototypal inheritance. When I created this object, you can see, I didn't add any properties to it, right? It's just an empty object. However, when I toString() on this object, I don't get an error, and instead, I actually get a return value.
2:06 There is also no limit to the number of nested prototypes you can have on an object. Here, I'm using object.create, which is a function that creates a new object and optionally takes a param, which will be the next-in-line Dunder prototype object.
2:21 If we take a look at what B looks like in our browser console, you can see more clearly that B is just an empty object. Its next-in-line prototype through this Dunder property is the A object. 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.
2:45 If we were to give the A object a property of toString(), where this new toString() property is a function that returns true, you can see that our console at log of B is now returning true.
2:57 If we throw this back in our browser console, we can see this prototypal inheritance more clearly. When we step through the Dunder property of the B object, we will see the A object that has this toString() method we've added.
3:10 We see the original toString() method on the global object prototype, which is nested within the A object's Dunder prototype object.
3:47 We saw that to be true with plain objects. It's also true for other sub-types of objects like arrays, maps, sets, and functions. You can see that here with an array, we have this Dunder array object. Those are all the methods we used when we worked with arrays.
4:02 Same thing with maps, when we create them. There's a Dunder proto map object that correlates with it. It has its own methods that we can use when we instantiate maps. Same thing with sets. It has a Dunder set prototype.
4:18 It's also true for functions. It has a functional prototype object that gives us methods that we can use when working with functions.