1. array-find
ES6 Array.find ponyfill. Return the first array element which satisfies a testing function.
array-find
Package: array-find
Created by: stefanduberg
Last modified: Mon, 13 Jun 2022 03:28:15 GMT
Version: 1.0.0
License: MIT
Downloads: 3,886,226
Repository: https://github.com/stefanduberg/array-find

Install

npm install array-find
yarn add array-find

array-find

Build Status

ES 2015 Array.find ponyfill.

Ponyfill: A polyfill that doesn't overwrite the native method.

Find array elements. Executes a callback for each element, returns the first element for which its callback returns a truthy value.

Usage

 var find = require('array-find');
var numbers = [1, 2, 3, 4];

find(numbers, function (element, index, array) {
  return element === 2;
});
// => 2

var robots = [{name: 'Flexo'}, {name: 'Bender'}, {name: 'Buster'}];

find(robots, function (robot, index, array) {
  return robot.name === 'Bender';
});
// => {name: 'Bender'}

find(robots, function (robot, index, array) {
  return robot.name === 'Fry';
});
// => undefined

Optionally pass in an object as third argument to use as this when executing callback.

Install

 $ npm install array-find

License

MIT

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code