Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including find-index with all npm packages installed. Try it out:

var findIndex = require("find-index")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

find-index v1.1.1

finds an item in an array matching a predicate function, and returns its index


An implementation of the ES6 method Array.prototype.findIndex as a standalone module and a ponyfill.

Finds an item in an array matching a predicate function, and returns its index.

Fast both when thisArg is used and also when it isn't.


npm install find-index
var findIndex = require('find-index/findIndex')
var findIndex = require('find-index/ponyfill') // will use native Array#findIndex if available.
var findLastIndex = require('find-index/findLastIndex') // search backwards from end
findIndex(array, callback[, thisArg])
findLastIndex(array, callback[, thisArg])
    The array to operate on.
    Function to execute on each value in the array, taking three arguments:
        The current element being processed in the array.
        The index of the current element being processed in the array.
        The array findIndex was called upon.
    Object to use as this when executing callback.

Based on array-findindex


$ iojs --harmony_arrays perf/benchmark.js

native Array.prototype.findIndex: 6347ms
findIndex: 1633ms
findIndex ponyfill: 6384ms
findLastIndex: 1508ms
npm lodash.findindex: 2900ms
npm array-findindex: 3512ms
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free