Inheritance in JavaScript really is one of its major strengths. Instead of classical class-based inheritance, JavaScript uses prototypal inheritance. (Protip: it's pronounced pro-to-TYPE-al not pro-to-TYPICAL.) That's because it uses the object's prototype as a template. Do you remember previously when we worked with the methods of a string and a number in the console and found a bunch of methods available to us even on a simple data type? Well, we can go further than that.
Fundamental to the concept of prototypal inheritance in JavaScript is the prototype chain, which tells us what we have access to in terms of methods. Let's take a look at a diagram:
So, what does this mean? Consider Alice: we can see that this variable is a string as it descends from the String prototype. So, translated into code, we can say the following:
const Alice = new String()
Alice.name = "Alice"
console.log...