June 2016
Beginner
248 pages
5h 18m
English
As mentioned earlier in this chapter, ECMAScript 2016 is a small release with only a couple of new features. These are an includes method for arrays and the exponentation operator **.
You can write myArray.includes(value) instead of myArray.indexOf(value) !== -1. Note that these expressions are not quite equivalent. You can use includes to check for the value NaN within an array, which you can't do with indexOf.
The exponential operator allows you to rewrite Math.pow(coefficient, exponent) as coefficient ** exponent.
You can also combine it with an assignment, as in myVariable **= 2.
Read now
Unlock full access