You are on page 1of 1
ES6 ECMAScript 2015 (also known as ES6 and often referred to as Harnory) is the oth major release of the ECMAScript language specification. I am going to cover the most important features here to get you started with ESo and then be able moving to TypeScript and Angular faster. Classes ‘The class syntax in JavaScript is not a new object-oriented inheritance model but simply a syntactical sugar on top of the existing prototype-based inheritance. Traditionally we have been using standard Objects and Prototypes like shown below: var Widget = function(id, x, y) { 2 this.id = id; 2 this eetPasition(x, y); at 5 Widgst prototype setPosition = function(x, y) { ° thie. 7 this.y ) With class syntax developers get more natural and boilerplate-free result class Widget { 2 construstor(id, x, y) { Q this.id = id; 4 this. setPosition(x, y); 5 } setPosition(x, y) this.x = x; thisy = y; ) “The constructor function is automatically called when you create a new instance of Widget:

You might also like