A quick overview of new JavaScript features in ES2015, ES2016, ES2017, ES2018 and beyond.
Block scoping
Let
Const
let
is the new var
. Constants work just like let
, but can’t be reassigned. See: Let and const
Backtick strings
Binary and octal literals
New methods
New string methods
See: New methods
Classes
Constructor
Methods
Calling superclass methods
Static methods
Syntactic sugar for prototypes. See: Classes
Exponent operator
#Promises
Making promises
For asynchronous programming. See: Promises
Using promises
Using promises with finally
The handler is called when the promise is fulfilled or rejected.
Promise functions
Async-await
async
functions are another way of using functions.
See: async function
#Destructuring
Destructuring assignment
Default values
Default values can be assigned while destructuring arrays or objects.
Function arguments
Destructuring of objects and arrays can also be done in function arguments.
Default values
Reassigning keys
This example assigns x
to the value of the left
key.
Loops
The assignment expressions work in loops, too.
Object destructuring
Extract some keys individually and remaining keys in the object using rest (…) operator
#Spread
Object spread
with Object spread
without Object spread
The Object spread operator lets you build new objects from other objects.
See: Object spread
Array spread
with Array spread
without Array spread
The spread operator lets you build new arrays in the same way.
See: Spread operator
#Functions
Function arguments
Fat arrows
#Objects
Shorthand syntax
Methods
Getters and setters
Computed property names
Extract values
#Modules
Imports
import
is the new require()
. See: Module imports
Exports
export
is the new module.exports
. See: Module exports
#Generators
Generators
It’s complicated. See: Generators
For..of iteration
For iterating through generators and arrays. See: For..of iteration
Comments
Post a Comment