ES6 Class in 5 minutes
Sep 7, 2018 · 1 min read

We know the purpose of classes in sense of programming concepts.
In JavaScript class is the makeover upon traditional prototype-inheritance.
ES5 Approach
function Person(first, last) {
this.first = first;
this.last = last;
}Person.prototype.firstName = function() {
console.log(this.first);
}Person.prototype.lastName = function() {
console.log(this.last);
}Person.prototype.fullName = fucntion() {
console.log(this.first + ' ' + this.last);
}var me = new Person('Hashir','Hussain');
console.log(me.fullName()); //Hashir Hussain
ES6 Approach
class Person() {
constructor(first, last) {
this.first = first;
this.last = last;
}
firstName() {
console.log(this.first);
}
lastName() {
console.log(this.last);
}
fullName() {
console.log(this.first + ' ' + this.last);
}
}var me = new Person('Hashir','Hussain');
console.log(me.fullName()); //Hashir Hussain
Above code is available here.
