DEV Community

Discussion on: 8 JavaScript array methods you should know

Collapse
joelynn profile image
Joseph Lynn Author

@rafaelrochas91 I believe we are saying the same thing. However, I did notice a copy/paste error in the title. I had Array.indexOf(callback). Just changed it to Array.indexOf(item). Thanks for the feedback!

"The indexOf() method returns the first index at which a given
element can be found in the array, or -1 if it is not present."

So if we had an array of something silly like:

const arr = ['hello', 'hello', 'hello']
// only the first item in the array will be returned. 
console.log(arr.indexOf('hello')) 
// => 0
Enter fullscreen mode Exit fullscreen mode
Collapse
rafarochas91 profile image
Rafael Rocha

Yes exactly.
You're welcome, good post nonetheless!

Thread Thread
joelynn profile image
Joseph Lynn Author

Much appreciated!