DEV Community

Discussion on: Can someone explain that logic to me?

Collapse
 
j4s0nc profile image
Jason C

The indexOf() method returns the position of the first occurrence of a specified value.

This method returns -1 if the value to search for never occurs.

Collapse
 
codandcode profile image
Marmot

Ok, so it's just a rule that I should remember :) Thank you so much.

Collapse
 
j4s0nc profile image
Jason C

Javascript is a mystic beast ;-)

When in doubt about a function I typically turn to w3schools

Thread Thread
 
codandcode profile image
Marmot

I will add that to my bookmarks. Thanks!