You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

array-find-last

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-find-last

Add findLast and findLastIndex to Array.prototype. The findLastIndex() method returns the index of the last element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test. The findLa

1.0.1
latest
npmnpm
Version published
Weekly downloads
881
-13.88%
Maintainers
1
Weekly downloads
 
Created
Source

array-find-last

Add findLast and findLastIndex to Array.prototype. The findLastIndex() method returns the index of the last element in the array that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test. The findLast() method returns the value of the last element in the provided array that satisfies the provided testing function. If no values satisfies the testing function, undefined is returned.

Install

npm install array-find-last

Use

# es6
import 'array-find-last';
require('array-find-last');

Example

import 'array-find-last';

const array1 = [5, 12, 8, 130, 44];

const foundLast = array1.findLast(element => element > 10);

const foundLastIndex = array1.findLastIndex(element => element > 10);

console.log(foundLast);
// expected output: 44

console.log(foundLastIndex);
// expected output: 4

FAQs

Package last updated on 10 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts