Array.prototype.findIndex ES6 polyfill for ES5 versions and lower.
npm install jspolyfill-array.prototype.findIndex -
Based from Mozilla polyfill.
1. Require the npm module.
``js`
npm install --save-dev jspolyfill-array.prototype.findIndex
2. Include the file before the usage.
Then you need to require the file on your main.js or where you arefind
going to plan to use the function as follows:
`js`
require("jspolyfill-array.prototype.findIndex")
`js`
arr.findIndex(callback[, thisArg])
Where arr is your array.
- callback Function to execute on each value in the array, taking three arguments:element
- The current element being processed in the array.index
- The index of the current element being processed in the array.array
- The array findIndex was called upon.thisArg
- Optional. Object to use as this when executing callback.
The callback passed as a parameter inside of the findIndex function istrue
fired every time per each element inside of the array until finds an
element where the callback evaluates to .
It returns the index of the first match otherwise if no match is found it will return -1`.
For more information click here.