|ECMAScript 2016 Approved|
|Written by Ian Elliot|
|Thursday, 23 June 2016|
There are two small new features.
You can now perform a functional programming like search of an array for a particular element. That is instead of:
You can now write:
That is, array.includes(el) is true if el is an element of the array. Of course you could have done something similar before using indexOf:
However, includes is more expressive of what you mean.
There are also some minor differences between indexOf and includes. For example, it will match NaN and undefined.
Useful but hardly a revolution.
The second new feature is long overdue if you write any sort of numerical number crunching program.
The correct way to raise to a power is to use Math.pow(x,2) which doesn't look good and looks even worse when you use it in a formula, for example:
At long last you can now write raise to a power using the old Fortran ** operator and formulas look a lot better for it:
Of course for small powers it still usually better to write x*x for x squared:
So that's it - ES 2016 summed up.
Welcome additions but not much to show for a year's worth of deliberations.
With big changes you can make a conscious decision to write in a clear subset of the language small changes mean you have a whole set of things to keep in mind. Imagine in a few years time when you need to look at a "can I use" matrix for ES2020.
But the world isn't ideal.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Thursday, 23 June 2016 )|