ES6 Class

1 min read
Before we start learn ES6 why we need ES6 class in Javascript. So let’s find it:
Before ES6, JavaScript had no concept of classes. It’s use functions, for example:
function Person(name) {
this.name = name;
}
Person.prototype.getName = function () {
return this.name;
};
var john = new Person("John Doe");
console.log(john.getName()); // Output : John Doe
Let’s know how above example is work.
0
Subscribe to my newsletter
Read articles from DG9222 directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
