Skip to content
Advertisement

How Do I return the index of an object in an array -Javascript

How can I return the index of an object based on the key value in the object if the objects are in an array like the following.

JavaScript

Advertisement

Answer

You can user findIndex

JavaScript

If you have to search with same prop over and over again you can create a separate function for that.

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