ES2016 features (ES7)

Tram Ho

1. includes ()

With this feature, when we check to see if an array contains an element, we can write in a more readable syntax.

In ES6 and earlier versions, to check if the array contains an element, you must use indexOf to check the index of the element and get -1 if the element is not in the array.

Because -1 is counted as a true value, checking the element in the array as follows will not work:

As for includes() in ES7, we can do it:

2. Exponentiation operator

The exponentiation operator ** is equivalent to Math.pơ() , but it is inserted directly into the JavaScript language instead of being a library function.

This feature is a good socks supplement especially for math-intensive JS applications.

The ** operator has been standardized in many languages ​​including Python, Ruby, MATLAB, Lua, Perl and many others.

Over! New features in ES2016 only this much sir. You can read more about ES2017 features in the following article .

Share the news now

Source : Viblo