ES6 APIs & Features

ES6 (ECMAScript 2015) was a major update introducing arrow functions, classes, modules, destructuring, and many other modern JavaScript features that transformed the language.

Released: June 2015
Modern JavaScript
ECMAScript

Other JavaScript Versions

Release Information

Release Date:

June 2015

Version Type:
Modern

Quick Summary

ES6 (ECMAScript 2015) was a major update introducing arrow functions, classes, modules, destructuring, and many other modern JavaScript features that transformed the language.

Top Features

  • Arrow Functions
  • Classes
  • Modules (import/export)
  • Destructuring Assignment
  • Template Literals
  • Default Parameters
  • Rest/Spread Operators
  • let and const
  • Promises
  • Map and Set

Playground

Try out JavaScript code examples and experiment with features in the official TypeScript playground.

Open JavaScript Playground

API Examples

Arrow Functions

Shorter syntax for writing function expressions with lexical this binding.

// Traditional function
function add(a, b) { return a + b; }

// Arrow function
const add = (a, b) => a + b;

// With single parameter
const square = x => x * x;

Classes

Syntactical sugar over JavaScript's prototype-based inheritance.

class Person {
  constructor(name) {
    this.name = name;
  }
  
  greet() {
    return `Hello, ${this.name}!`;
  }
}

const person = new Person("John");
console.log(person.greet()); // Hello, John!

Destructuring Assignment

Extract values from objects and arrays into distinct variables.

// Array destructuring
const [a, b, ...rest] = [1, 2, 3, 4, 5];
console.log(a, b, rest); // 1, 2, [3, 4, 5]

// Object destructuring
const { name, age } = { name: "John", age: 30 };
console.log(name, age); // John, 30

Template Literals

String literals that allow embedded expressions and multiline strings.

const name = "World";
const greeting = `Hello, ${name}!
This is a multiline
string.`;

console.log(greeting);
// Hello, World!
// This is a multiline
// string.

Modules (import/export)

Native module system for organizing and sharing code.

// math.js
export const add = (a, b) => a + b;
export const multiply = (a, b) => a * b;
export default class Calculator {}

// main.js
import Calculator, { add, multiply } from "./math.js";
console.log(add(2, 3)); // 5