Skip to content

“Classes” coming in ES6(JavaScript)

ECMAScript 6 is the upcoming version of the ECMAScript standard. This standard is targeting ratification in June 2015. Implementation of these features in major JavaScript engines is underway now.

One of the main new feature to be introduced in ES6 is classes. Although ES is object-oriented to its core, with powerful, flexible OOP capabilities, yet it has been known as a prototype/object-based language rather than an object oriented language. Introducing classes will not change this nomenclature, but it makes JavaScript more aligned with other Object Oriented languages.

ES6 classes is just simple declarative form which makes class patterns easier to use, and encourages interoperability. Classes support prototype-based inheritance, super calls, instance/static methods and constructors.

This is how you might implement a Class in ES6

class NewClass extends DummyClass {
constructor(variableA, variableB) {
super(variableA, variableB);
this.id = NewClass.defaulIdGenerator();
this.elements = [];
//…
}
update(test) {
//…
super.update();
}
static defaultIdGenerator() {
return new DummyClass.Id();
}
}
Loading Disqus Comments ...
Loading Facebook Comments ...