GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Modul 8 von 14 · Medien

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?

Anleitung

Um im Kurs weiterzukommen, sende einen Versuch dieses Quiz ab. Du kannst ihn nach der letzten Frage absenden.

Zum gewählten Modul

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck