<commit_before>---
title: Hopping on the ES6 train
date:   2016-04-05 14:00:00
description: Understanding and applying some basic features from the new ECMAScript 2015 (ES6)
---

Remember our [last post](http://saviolucena.com/2016/understanding-javascript-event-emmiter/) where we reasoned about JavaScript events by building our own tiny EventEmitter library? So, today we'll re-factor that same code to make use of some new features introduced by ECMAScript 2015 (ES6).

> [ECMAScript](https://en.wikipedia.org/wiki/ECMAScript) is a scripting-language specification standardized by an organization called Ecma International. JavaScript is one of the implementations of this language.

Up to the day of this post the latest version of Node.js (v5.10.0) ships with **V8 (4.6.85.31)** engine which allows us to use [this](!https://nodejs.org/en/docs/es6/#which-features-ship-with-node-js-by-default-no-runtime-flag-required) set of features by default, without any additional runtime flags required. Today we'll take a brief look at three of those features:

- Classes
- Arrow Functions
- Const

> ***Runtime Flags*** - flags passed to a Node.js script call to make features not yet considered stable by V8 available. All ES6 features are split into three groups: **shipping** (stable), **staged** and **in progress**. Staged features can be enabled with the ***--es_staging or --harmony***, whereas in progress features must be enabled individually setting their respective harmony flag (--harmony_modules).

# Classes
Classes are being introduced in ECMAScript 6 and are just a syntactical sugar over the well known and existing prototype-based inheritance, meaning that the syntax used by **classes** is not introducing a **new** inheritance model to the language, it's just another way to implement the same model but with a more conventional syntax approach to create objects and deal with inheritance.

Classes are implemented in ES6 by the use of the ***class*** keyword followed by the name of the class.

``` javascript
class Emitter {
  ...
}
```

Everything inside of the curly brackets {} is the body of a class, and that's where you define class members, such as methods or constructors.<commit_msg>update link on old post<commit_after>---
title: Hopping on the ES6 train
date:   2016-04-05 14:00:00
description: Understanding and applying some basic features from the new ECMAScript 2015 (ES6)
---

Remember our [last post](http://saviolucena.com/2016/understanding-javascript-event-emmiter/) where we reasoned about JavaScript events by building our own tiny EventEmitter library? So, today we'll re-factor that same code to make use of some new features introduced by ECMAScript 2015 (ES6).

> [ECMAScript](https://en.wikipedia.org/wiki/ECMAScript) is a scripting-language specification standardized by an organization called Ecma International. JavaScript is one of the implementations of this language.

Up to the day of this post the latest version of Node.js (v5.10.0) ships with **V8 (4.6.85.31)** engine which allows us to use [this](https://nodejs.org/en/docs/es6/#which-features-ship-with-node-js-by-default-no-runtime-flag-required) set of features by default, without any additional runtime flags required. Today we'll take a brief look at three of those features:

- Classes
- Arrow Functions
- Const

> ***Runtime Flags*** - flags passed to a Node.js script call to make features not yet considered stable by V8 available. All ES6 features are split into three groups: **shipping** (stable), **staged** and **in progress**. Staged features can be enabled with the ***--es_staging or --harmony***, whereas in progress features must be enabled individually setting their respective harmony flag (--harmony_modules).

# Classes
Classes are being introduced in ECMAScript 6 and are just a syntactical sugar over the well known and existing prototype-based inheritance, meaning that the syntax used by **classes** is not introducing a **new** inheritance model to the language, it's just another way to implement the same model but with a more conventional syntax approach to create objects and deal with inheritance.

Classes are implemented in ES6 by the use of the ***class*** keyword followed by the name of the class.

``` javascript
class Emitter {
  ...
}
```

Everything inside of the curly brackets {} is the body of a class, and that's where you define class members, such as methods or constructors.
{'fraction_non_alphanumeric': 0.08143469433792014, 'fraction_numerical': 0.020302278366794498, 'mean_word_length': 4.577358490566038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5557643', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1104, 'n_words': 593}