Modern JavaScript beyond ES6
Nemanja Stojanovic
�LSE @ enki.com�@nem035 on the internet (nem035.com)
Why do we care?
🌕�🚀
Why do we care?
Why do we care?
https://octoverse.github.com/projects
Why do we care?
NPM (registry of JS packages) is the largest package registry in the world
Why do we care?
NPM (registry of JS packages) is the largest package registry in the world
Why do we care?
According to Stack Overflow’s Annual Survey of 2018, for the sixth year in a row, JavaScript is the most commonly used programming language.
Why do we care?
(Jeff) Attwood’s Law (co-founder of StackOverflow):
any application that can be written in JavaScript, will eventually be written in JavaScript.
What can we code in JS?
What is ECMAScript?
Quick History
What is ES6?
Quick History
Why add new features?
Why add new features?
Why add new features?
New features also allows us to do...
...fun meta things :)
Most features in latest ECMAScript releases are extensions to existing native functions
How does this work?
Functions - first class citizens
*.prototype.<method>
*.prototype.<method>
Static methods
So what’s new in JS after ES6?
ECMAScript2016 (ES7)
*Smallest release with only 2 features
Array.prototype.includes
Array.prototype.includes
Array.prototype.includes
** infix operator
ECMAScript2017 (ES8)
Object.values
Object.values
Object.entries
Object.entries
String.prototype.padStart
String.prototype.padEnd
padStart+padEnd
padStart+padEnd
Output
Trailing commas in parameters
Trailing commas in parameters
Trailing commas in parameters
Async/await
Async/await
Async/await
Before
After
ECMAScript2018 (ES9)
Rest vs Spread in ES6 ...
Object rest (...) operator
Object rest (...) operator
Object spread (...) operator
Promise.prototype.finally
Promise.prototype.finally
Async iteration
How does async iteration work?
First thing’s first, how does sync iteration work?
How does iteration work?
What is an iterable?
What is an iterator?
What is an iterator?
What is an iteratorResult?
Let’s try it out!
Running a custom iterator
Manually
Using for of
No need for custom iterator.
Use ES6 generators
Ok but what about async iteration?
Sync vs Async iterable
ECMAScript2018 brings us a lot of Regex goodies
What’s a regex?
\s regex flag
RegExp Named Group Captures
What is a capture group?
RegExp Named Capture Groups
RegExp Named Capture Groups
New RegExp lookaround
We already have RegExp look-ahead
ES2018 gives us look-behind
Look ahead
Look behind
Practical examples
RegExp unicode property escape
...we can also match emoji 🤓
The future is (almost) here
ECMAScript2019 (ES10)
String.prototype.matchAll()
How can we get all matches now?
How can we get all matches now?
String.prototype.matchAll()
String.prototype.matchAll()
String.prototype.matchAll()
Dynamic imports?
ES6 imports
Dynamic imports
Dynamic imports
Dynamic imports
Array.prototype.flat()
Array.prototype.flat()
Array.prototype.flatMap()
String.prototype.trimStart()
String.prototype.trimEnd()
Private class members
Thank you
Nemanja Stojanovic
�LSE @ enki.com�@nem035 on the internet (nem035.com)