Skip to content
Advertisement

Javascript findIndex is not a function

I have a json array:

JavaScript

function to remove a item from json array

JavaScript

When the code is running there is an error:

findIndex is not a function

error line

JavaScript

Advertisement

Answer

findIndex is not a prototype method of Array in ECMASCRIPT 262, you might need filter combined with indexOf, instead, it has the advantage of stopping searching as soon as entry is found

JavaScript

EDIT as suggested in comments by Nina Scholz:

This solution is using Array.prototype.some instead

JavaScript

Found at Array.prototype.findIndex MDN

enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement