Skip to content

Polyfill for the The findIndex() method. returns an index in the array, if an element in the array satisfies the provided testing function. Otherwise -1 is returned.

License

Notifications You must be signed in to change notification settings

jsPolyfill/Array.prototype.findIndex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Array.prototype.findIndex ES6 polyfill for ES5 versions and lower.

Array.prototype.findIndex ES6 polyfill for ES5 versions and lower via NPM, you only need to require the module in order to have it working in order to use knowing that is going to work in browsers that does not support this function natively.

Build Status - Based from Mozilla polyfill.

Installation.

  1. Require the npm module.
npm install --save-dev jspolyfill-array.prototype.findIndex
  1. Include the file before the usage.

Then you need to require the file on your main.js or where you are going to plan to use the find function as follows:

require("jspolyfill-array.prototype.findIndex")

Usage

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 is fired every time per each element inside of the array until finds an element where the callback evaluates to true.

It returns the index of the first match otherwise if no match is found it will return -1.

For more information click here.

About

Polyfill for the The findIndex() method. returns an index in the array, if an element in the array satisfies the provided testing function. Otherwise -1 is returned.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published