A demonstration of some ECMAScript 6 features.

Also known as ES6 and ES2015.

Below are interactive examples of various ES6 features. Code in the first box is interpreted and the results are displayed in the second box. Only the final value is displayed in the 2nd box. If you want to show more than 1 value, concatenate multiple values into a single string.

Const

const declares a constant value which cannot be changed.

Let

let lets you declare block level variables while variables declared with var are visible throughout the function.


Arrow Functions

Functions can be implicitly declared via an arrow- => .

Default Parameters

Parameters for functions can have default values.

Spread Operator

The spread operator (...) allows you to pass an arbitrary number of values to a function which are concatenated to a single array.




The spread operator can also split a string or array into individual elements.

String Repeating
String Interpolation

By using backticks, you can mix strings, variables and code.

Method Shorthand

Object methods can be declared implicitly.