In previous article, we saw how to create classes, constructors, properties and methods.
In Next Generation JavaScript, we skip constructor function and use Arrow functions for our methods. We can directly declare parameters.
Let’s see below example:
class Person{
name = "Akanksha";
address = "Delhi";
getPersonDetails = () => {
console.log("Name: " + this.name);
console.log("Location: " + this.address);
}
}
class Student extends Person{
cls = "12th";
getStudentDetails = () => {
console.log("Class: " + this.cls);
}
}
const student = new Student();
student.getPersonDetails();
student.getStudentDetails();

