I found the following page to test:
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex
I have the following code for this, but it doesn't work:
// ==UserScript==
// @name Inject findLastIndex
// @version 0.0.1
// @description try to take over the world!
// @match *://*/*
// @run-at document-start
// @grant none
// ==/UserScript==
if (!Array.prototype.findLastIndex) {
'use strict';
Object.defineProperty(Array.prototype, "findLastIndex",
{
value: function (predicate, thisArg) {
let idx = this.length - 1;
while (idx >= 0) {
const value = this[idx];
if (predicate.call(thisArg, value, idx, this)) {
return idx;
}
idx--;
}
return -1;
}
,
writable: true,
enumerable: false,
configurable: true
});
}
What am I doing wrong?