Object-Oriented JavaScript

As ECMAScript 6 seems to be more in the focus recently, I decided to read and prepare for the upcoming features.
In case you would like to write your code using the new ES6 features, most likely it will not work with a wide range of frameworks. That's why you might try 6to5 to turn your code to ES5 compliant.

One of the useful ES6 features is the class. I believe more people would use the object-oriented programming paradigm in JavaScript if they could use something that they are more familiar with. Maybe you don't agree with me, but in case you are extending a "class" it is easy to make mistakes.
I found a detailed explanation of JavaScript's prototype-based object-orientation at Mozilla Developer Network where the background of the concept is detailed very well. Based on that, I created an example on how to use the prototype-based objects properly:

Then, I rewrote the code above to a version using the "class" feature of ES6.

As I mentioned, this code is currently not supported widely, so you have to get the ES5 version before. For that, I used 6to5 as follows:

$ sudo npm install 6to5 -g
$ 6to5 class-ES6.js > class-ES5.js

On the website of 6to5, you can also found a very detailed overview of the ES6 features that I highly recommend to read. If you would like to know even more, I recommend you to read the Understanding ECMAScript 6 book.