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 declares a constant value which cannot be changed.
let lets you declare block level variables while variables declared with
var are visible throughout the function.
Functions can be implicitly declared via an arrow-
Parameters for functions can have default values.
Simulate named parameters via destructuring.
You can use defaults as well.
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.
By using backticks, you can mix strings, variables and code.
Object methods can be declared implicitly.
** operator to perform exponentiation.
Object.values to get an array of the values in an object.
Object.entries to get an array of the entries in an object.
This way you can loop through all of the entries in an object like an array.