This is the third in a series of posts where I explore all the new stuff es6 has to offer, come along and learn about classes.
ECMAScript 6 introduces the class syntax, I suppose the first thing we would need to figure out is what does it replace or it’s equivalent in es5, so.
In a nutshell, if you already know about prototypes you alaready know how a class works, it is basically syntactical sugar (a more readable or convenient way) to deal with objects and inheritance.
This being a programming language, there is nunance and variation when defining a class, so..
A lot of what makes an object useful is the internal machinery as I like to call it or Methods as most people do, let’s figure out how to make some methods with es6 classes:
Another handy thing one can do with classes is extending them so they add or change behaviour from a base class (or prototype) , let’s try that:
One last things we must investigate, is how does one refer to the original class within an extended class?
Classes in es6 = delicious prototype/inheritance sugar