UNPKG

@opra/common

Version:
22 lines (21 loc) 671 B
if (!Array.prototype.findLast) { Array.prototype.findLast = function (predicate, thisArg) { const i = this.findLastIndex(predicate, thisArg); return i >= 0 ? this[i] : undefined; }; Array.prototype.findLastIndex = function (predicate, thisArg) { if (this == null) { throw new TypeError('this is null or not defined'); } const arr = Object(this); const len = this.length; thisArg = thisArg || this; for (let i = len - 1; i >= 0; i--) { if (predicate.call(thisArg, arr[i], i, arr)) { return i; } } return -1; }; } export {};