Member-only story
ES6 / ECMAScript2015
1. A Deep Dive into the Latest JavaScript Features — ES6
The JavaScript has been evolved a lot and one of the widely used language in the world. We are discussing about some core feature of ES6 / ECMAScript 20175 / ECMA2015, the iteration of the ECMAScript standard. Let’s talk about exciting features that can streamline your workflow and enhance your code.
In this article, we’ll delve into some of the key features introduced in ES6:
1. Arrows
- Arrows are a function shorthand using the => syntax.
- An arrow function expression is a compact alternative to a traditional function expression, but is limited and can’t be used in all situations
// Expression bodies
var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
var pairs = evens.map(v => ({even: v, odd: v + 1}));
// Statement bodies
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
});- Does not have its own bindings to this or super, and should not be used as methods
// Lexical this
var bob = {
_name: "Bob",
_friends: [],
printFriends() {
this._friends.forEach(f =>
console.log(this._name + " knows " + f));
}
}Note:
- Does not have arguments










