1. array.prototype.findlast
An ESnext spec-compliant `Array.prototype.findLast` shim/polyfill/replacement that works as far down as ES3.
array.prototype.findlast
Package: array.prototype.findlast
Created by: es-shims
Last modified: Tue, 19 Mar 2024 17:21:11 GMT
Version: 1.2.5
License: MIT
Downloads: 17,391,407
Repository: https://github.com/es-shims/Array.prototype.findLast

Install

npm install array.prototype.findlast
yarn add array.prototype.findlast

array.prototype.findlast Version Badge

github actions
coverage
dependency status
dev dependency status
License
Downloads

npm badge

An ESnext spec-compliant Array.prototype.findLast shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.

Because Array.prototype.findLast depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Getting started

 npm install --save array.prototype.findlast

Usage/Examples

 var findLast = require('array.prototype.findlast');
var assert = require('assert');

var arr = [1, [2], [], 3, [[4]]];
var isNumber = function (x) { return typeof x === 'number' };

assert.deepEqual(findLast(arr, isNumber), 3);
 var findLast = require('array.prototype.findlast');
var assert = require('assert');
/* when Array#findLast is not present */
delete Array.prototype.findLast;
var shimmed = findLast.shim();

assert.equal(shimmed, findLast.getPolyfill());
assert.deepEqual(arr.findLast(isNumber), findLast(arr, isNumber));
 var findLast = require('array.prototype.findlast');
var assert = require('assert');
/* when Array#findLast is present */
var shimmed = findLast.shim();

assert.equal(shimmed, Array.prototype.findLast);
assert.deepEqual(arr.findLast(isNumber), findLast(arr, isNumber));

Tests

Simply clone the repo, npm install, and run npm test

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin