Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What Is ES6? ECMAScript 2015 Features With Examples

Learn what ES6 added to JavaScript, including block scope, arrow functions, destructuring, promises, classes, and modules.

Table of Contents

ES6, also called ECMAScript 2015, is the sixth edition of the standard that defines JavaScript. It introduced features such as let, const, arrow functions, destructuring, promises, classes, and modules. Later editions have added more features.

What is ES6? Features and Benefits of ES6 over JavaScript Picture 1

Features you’ll see in everyday JavaScript

FeatureExample and use
Block-scoped variablesconst items = [] prevents reassigning items, while items.push('book') still works. Use let when the binding needs to change.
Arrow functionsitems.map(item => item.toUpperCase()) applies a short callback. An arrow captures this from its surroundings.
Destructuringconst { name } = user reads a named property. const [first] = items reads the first array element.
Default argumentsfunction greet(name = 'Guest') { /* … */ } uses the default if the argument is missing or undefined.
Template literals`Hello, ${name}!` inserts an expression into text.
Array spread and rest parameters[...items, 'pen'] expands values into a new array. function list(...values) { /* … */ } collects arguments into an array.

What is ES6? Features and Benefits of ES6 over JavaScript Picture 2

ES6 is the ECMAScript edition published in 2015.

What changed for larger programs

  • Modules: Use export and import to define what each file shares. In browsers, load a module script with type="module".
  • Promises: Use .then() for a result and .catch() for a rejection. async and await came later and build on promises.
  • Classes: Use class and extends to organize behavior. JavaScript still uses prototypes under the class syntax.

What is ES6? Features and Benefits of ES6 over JavaScript Picture 3

ES6 gave developers more ways to organize and reuse JavaScript code.

Check compatibility before changing older code

Modern browsers and supported Node.js releases handle ES6. For legacy browsers, check both the syntax and built-in features you use. A transpiler can rewrite some syntax, while missing built-ins can require a polyfill. See the ECMAScript 2015 specification or practice with the JavaScript Fundamentals course.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.