It’s much more pleasant to use it now than ever.
In this article, we’ll look at some instance methods of
Array and holes.
findIndex method lets us return the index of the item that’s found.
It takes a callback that returns the condition that we’re looking for.
The 2nd argument is the value of
this we use inside the callback.
It returns the index of the first element that meets the given condition.
If none is found, then -1 is returned.
For example, we can write:
const index = [2, -1, 6].findIndex(x => x < 0)
Does your business need an interactive website or app?
The technology used to develop the overall app by the developers from WebClues Infotech is at par with the latest available technology.
For more inquiry click here https://bit.ly/31eZyDZ
Book Free Interview: https://bit.ly/3dDShFg
It checks all the items of the Array, and whichever the first item meets, the condition is going to print. If more than one item meets the condition, then the first item satisfying the requirement is returned. Suppose that you want to find the first odd number in the Array. The argument function checks whether an argument passed to it is an odd number or not.
I see people using older functionalities and methods and I wonder why do people stick to older syntaxes rather than the newer ones. Lets see the newer implementations and how it overcomes the older ones below!!!