Skip to content

BendingBender/MDN-Array.prototype.find

Repository files navigation

browser support

Build Status

ES6 Array.prototype.find shim

Simple ES6 Array.prototype.find polyfill for older environments taken from MDN.

For browsers only, bower-friendly. Explicitly not meant to be used with node, use Array.prototype.find if you wish a shim for node.

Installation

  • Just include repo before your scripts.
  • bower install mdn-array.prototype.find

Usage

  • Array.prototype.find(predicate[, thisArg]) returns first item that matches predicate function.

Parameters

  • predicate(value, index, collection): takes three arguments
    • value: current collection element
    • index: current collection element index
    • collection: the collection
  • thisArg: Optional. Object to use as this when executing predicate.

Code example

[1, 5, 10, 15].find(function (a) { return a > 9; }) // 10

Acknowledgements

Tests, readme and travis support gratefully taken from Array.prototype.find

License

CC0 1.0

About

MDN version of Array.prototype.find shim

Resources

License

Stars

Watchers

Forks

Packages

No packages published