Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 1.51 KB

README.md

File metadata and controls

39 lines (24 loc) · 1.51 KB

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