Previously, for creating classes before ES6 we would do it this way:
Now with ES6, we can use the class syntax:
If you want to check and see whether these are the same, you can run a typeof on both of them and you will see that both are of type function!
As you can see above, both Cat and Dog inherit the same feed() method, but they both have their own methods meow() and bark() that only those instances can reference!
Hope you enjoy this little JS snippet!
Thanks for reading today!
Shoot me a message if you have any thoughts,
feedback, or criticisms. I would love to hear them.