ECMAScript: ES6

Mostafa Talaat
DSC Alexandria
2 min readJan 29, 2021

--

ECMAScript is a strong core pillar of web development. People behind it try to introduce new features, change, or fix existing ones.

In this article of our series of ECMAScript, we will talk about ECMAScript 2015 or ES6. It was released in 2015 as the 6th edition with major new and exciting features. ES6 is a significant update to the language, and the first update to the language since ES5 was standardized in 2009.

What is new in ES6?

Const and Let

Block-scoped binding constructs. const is single-assignment. let is a block-scoped variable assignment to remove any unintended output, unlike var. Static restrictions prevent use before assignment.

Arrow Function

Arrow functions allow a short syntax for writing function expressions. They support both statement block bodies as well as expression bodies which return the value of the expression. Unlike functions, arrows share the same lexical this as their surrounding code. You can only omit the return keyword and the curly brackets if the function is a single statement. Because of this, it might be a good habit to always keep them.

Default, Rest, and Spread

Simple and intuitive default values for function parameters. Aggregation of remaining arguments into a single parameter of variadic functions. Spreading of elements of an iterable collection (like an array or even a string) into both literal elements and individual function parameters.

Template Strings

Template strings provide syntactic sugar for constructing strings. Intuitive expression interpolation for single-line and multi-line strings. Optionally, a tag can be added to allow the string construction to be customized, avoiding injection attacks or constructing higher-level data structures from string contents.

Destructuring

Destructuring allows binding using pattern matching, with support for matching arrays and objects. Destructuring is fail-soft, similar to standard object lookup object["property"], producing undefined values when not found.

ES6 was a major upgrade to ES5. It added a lot to the web development field. It introduced many features but the important ones were highlighted.

Interested enough to know what was next in the ECMAScript world? stay tuned for the next article in this series!

--

--