I mentioned in the previous movie that because prototypal inheritance isn't understood by those coming from other programming languages that JavaScript has made attempts to make its prototypal inheritance look more like the way other languages handle inheritance. Well ESX has gone even further with that and and has adapted more of those keywords that are used in other languages. Now, I wanted to introduce this but be aware this really doesn't change the way prototypal inheritance works. It's just another syntactic structure to accomplish the same thing. Some of those same things we've been doing in past movies. Now there are a few differences that they added with the class keyword, which is what we're going to talk About that overcomes some of the issues that can occur with constructor functions.
For example, I mentioned with constructor functions, you need to make sure to remember to use the new keyword, or you run into problems while with this new syntactic structure that uses the class keyword. You're not allowed to do it without the new keyword. And so some things like that have been corrected. Now, I just want to show you what it is. So you're aware of it is something you're probably going to see, you may find it easier to use and creating objects than some of these other methods we've looked at. And that's great as well.
In fact, one thing I like about it is everything is tied together better. That's one thing I like about this structure. Now, I'm going to show you the previous example that we did. But I'm going to show you how we would have accomplished the same thing. Using the class keyword, okay, the previous example we set up our constructor function. And then we add it to the prototype, we added a method to that prototype against score method.
All right. Now with the class keyword, everything is defined within a class that class uses curly braces to enclose its entire definition. inside of that we have a constructor function created. So this constructor function is going to do basically what we've done up here, okay, notice that the structure that is exactly the same except for the first line, all right, we simply have the word constructor, then we have all the parameters that can be passed in. Then still inside that class definition, we have the get store method which we define So that's basically going to add that to the prototype. Now the rest of our code can be exactly the same.
We don't need to change it at all. I have not changed it at all. So let's just run this without the previous constructor function, doing it with a class definition. So in sublime, I can come out, comment out that whole thing using Command Option slash. And then I'll save it and then let's pull this up again. So we can take a look at whether or not we get the same results using the class definition, open the console.
And sure enough, we do get the same results. So that was to introduce to you the class keyword and the way classes can now be defined in ies six. Another way to use prototypal inheritance with With objects and to create objects. All right, let's move on to the exercises.