Get the nth index of the target in subject.

This function is valid in v2.8.0 to v2.12.0. This function has been downloaded 12 times.


{Array|string} subject
Array or string to search for target in.
{Function|RegExp} target
If subject is an array this must either be a function or a regular expression which will be tested against each element in subject. If subject is a string this must be a regular expression which will be tested against it to find all of the matches.
{number} n
The number of the occurrence that will be searched for and returned. 0 represents the first occurrence whereas -1 represents the last.


If the nth occurrence of target can be found within subject the index will be returned otherwise undefined will be returned.

Required Function

This function requires the following function which is included automatically:

  • findNth()
    Gets the nth value matching target in subject.