DEV Community

mzakzook
mzakzook

Posted on

Inspecting ES6

While several editions have been released since ES6 was released in 2015, it remains one of the most impactful updates to JavaScript (and JScript & ActionScript). ECMAScript "is a scripting-language specification standardized by Ecma International. It was created to standardize JavaScript to help foster multiple independent implementations... ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used for writing server applications and services using Node.js." - Wikipedia (https://en.wikipedia.org/wiki/ECMAScript).

ES6 was particularly noteworthy for several reasons:

  1. Better scope management with new variable keywords 'let' & 'const'.
  2. Less cluttered and more digestible code with addition of arrow functions.
  3. More universally intuitive syntax with ability to create classes.
  4. More powerful functions with ability to set default parameter values.
  5. Better efficiency with additions of 'Array.find()' & 'Array.findIndex()'.
  6. Easier exponentiation with addition of '**'.

The addition of the variable keywords 'let' and 'const' improved on the existing variable keyword 'var'. Before ES6, variables either belonged to function scope or global scope. The addition of 'let' and 'const' allowed for block scope. This created less buggy code.

Arrow functions are helpful in creating concise code. While a normal function declaration requires at least 3 lines of code, an arrow function can often accomplish the same in one line.

Though both classes and functions are actually objects in JavaScript, the ability to use either allows programmers coming from different disciplines to write intuitive and powerful code without a steep learning curve.

The ability to set default parameter values can greatly increase the effectiveness of your function. This allows for inputs that may not contain all the information that other inputs contain.

The additions of 'Array.find()' and 'Array.findIndex()' allows for quick and powerful solutions to array problems. It is common to use one of these built-in functions when dealing with an Array that contains one desired element.

For any programmers that like their code to mirror the way they think about a problem, the '' operator was a welcome addition. Before ES6 programmers used the 'Math.pow()' function for exponentiation. The addition of '' allows programmers to write code that looks similar to how one would write exponentiation on paper.

These updates were just some of many that were included with ES6. While ECMAScript is constantly evolving, I felt that ES6 was a special iteration and was worth exploring.

Sources:

https://www.w3schools.com/js/js_es6.asp

Top comments (0)