It’s hard to keep track of what’s new in JavaScript (ECMAScript). And it’s even harder to find useful code examples.
So in this article, I’ll cover all 18 features that are listed in the TC39’s finished proposals that were added in ES2016, ES2017, and ES2018 (final draft) and show them with useful examples.
This is a pretty long post but should be an easy read. Think of this as “Netflix binge reading.” By the end of this, I promise that you’ll have a ton of knowledge about all these features.
OK, let’s go over these one by one.
1. Array.prototype.includes
includes
is a simple instance method on the Array and helps to easily find if an item is in the Array (including NaN
unlike indexOf
).
Trivia: the JavaScript spec people wanted to name it
contains
, but this was apparently already used by Mootools so they usedincludes
.