New Array Prototype Methods
This is going to be very useful for returning a value at a particular index in the array without having to iterate through. This great improve the time complexity to O(1) which is the best.
_10const array = [5, 12, 8, 130, 44];_10_10array.at(2); // 8
.at() makes the code looks sweet, short and simple.
As we know, the
.find() method is one of the most commonly used method to-date. The
.findLast() is the opposite where it iterates the array in a reverse order. This is so useful if I want to search for a value that appear the last.
_10const array = [5, 12, 50, 130, 44];_10_10array.findLast((item) => item > 45); // 130