[JS/ES6] Some questions about objects
I have two questions about the old/new (ES6) way to define objects. In old JS I can create a "class/prototype" like this: function myClass(property1, property2, ...) { this.property1 = property1; this.property2 = property2; ... ; } But how about calculations inside the class definition? Is it possible in JS? My idea would be something like this: function car(color, date) { var now = new Date().getFullYear(); this.color = color; this.date = date; this.age = now - this.date; } And how do I create an "empty" class/prototype in ES6? This doesn't work since it's an object definition: let car = { color, date } How do I create classes in ES6? Is it possible? Many thanks in advance. Pete ____________________ P.S.: Take a look at my code https://code.sololearn.com/WM2DM8HXHxkb/?ref=app