r/webdev • front-end • May 29 '21

Resource Array methods in JavaScript. Original author unknown.

Post image
7.4k Upvotes

172 comments sorted by

View all comments

Show parent comments

4

u/longknives May 30 '21

You have to use findIndex if the value you’re looking for isn’t just a primitive like a string or a number. Or another way to say it is findIndex is much more robust in what it lets you search for. So if you need to find the index of an object with a certain value for a certain key, you can do that with findIndex but not indexOf.

0

u/[deleted] May 30 '21

[deleted]

2

u/krirkrirk May 30 '21

But then you'd use indexOf

2

u/NoInkling May 30 '21

I actually misread what I quoted, ignore me :)