GoConqr has a new look! Let us know what you think.

Module 8 of 14 · Media

Classes

Kostas Diakogiannis

Classes

Classes

Another way to create a blueprint for object that will be born later is to define a class. This relatively new (ES2015 way) method requires the class keyword followed by the name of the class.

Then we do exactly what we did before but this time inside a constructor function. This is exactly as before, and this is the function that will be executed any time an object uses this class alongside with the 'new' keyword in order to be created. Nothing changes (at least for now) and we can pass the arguments in order to populate our objects with different values inside the same properties.

Take a loop at the previous example below, this has exactly the same result as before.

Then why should someone bother with this syntax?

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?