Does the Array's find() method only return the first index that matches the value or every index ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By voodin

I’m looking to make a spawner script that places a spawner at a specific point2d in an array of point2d’s, but it only places a spawner there if there isn’t currently one.

If I for example, start with an array of 5 elements with element [0] filled, and I used find(0), would it return [1] ?

:bust_in_silhouette: Reply From: jgodfrey

Array.find() returns the first matching index, or -1 if no match is found. You can continue searching for further matches by utilizing the second, optional parameter that specifies the starting index for the search.