SIntaxe OOP JavaScript

2

I've been studying JavaScript a few days ago and realized that in object orientation, it seems to contain a number of ways to create objects and methods. Examples:

class Person {
constructor (firstName) {
this.firstName= firstName
}

or

const Person = function(firstName) {
this.firstname = firstName
}
Person.prototype.setName() {
}

What's the difference? Is there any more way used?

    
asked by anonymous 23.06.2018 / 17:31

0 answers