5 Most Exciting ES2022 Features You Should Know About
ECMAScript 2022 has been released for more than 2 months now, and it brings us a lot of exciting new features (as you’d know if you have used them).
These new features are great, some can optimize our code, and some improve the coding quality. Friends, what are you waiting for? Let’s take a look!
1. “.at()” method for arrays
How do you read the tail element of the array? Yes, we need to read with “array.length — 1” as a subscript.
Is there any other way?
ES2022 provides an array method called at
, which may be a small change, but it can greatly improve the readability of the code.
The at
method can take positive or negative numbers, and that will determine whether it starts reading elements from the head or the tail of the array.