Sitemap
Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Member-only story

ES6 / ECMAScript2015

3 min readFeb 14, 2024

--

Press enter or click to view image in full size

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

--

--

✅ open src 🚀 🚀
✅ open src 🚀 🚀

Written by ✅ open src 🚀 🚀

1. Open source contributor, Architect at Jio Platform Ltd. and The Author of fe-pilot. https://github.com/opensrc0/fe-pilot/

Stackademic
Stackademic

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.