Skip to main content
0:01est. 3 min

Chapter 64- ES6 and Classes

Notes

Just another way to create objects and set prototype
Js doesn't have classes however in the next version it will but in a different way
Example 1 :
//This class person is an object
class Person {
constructor(firstname, lastname){
this.firstname = firstname;
this.lastname = lastname;
}
greet(){
return ‘Hi' + firstname;
}
}
A js class define an object
var john = new Person(‘John','Doe');
//Setting up prototype with classes
class InformalPerson extends Person {
constructor(firstname, lastname){
super(firstname,lastname);
}
greet(){
return ‘Yo ' + firstname;
}
}

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance

#BIGWORD - Syntactic Sugar : A different way to Type something that doesn't change how it works under the hood.