findNth()

Gets the nth value matching target in subject.

This function is valid in v2.8.0 to v2.14.0. This function has been downloaded 45 times.

Parameters

{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.

Returns

{*}
The nth occurrence of target within subject. If not found undefined will be returned.

Required Functions

This function requires the following functions which are included automatically:

  • has()
    Every object descended from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of that object; unlike the in operator, this method does not check down the object's prototype chain.
  • findNthIndex()
    Get the nth index of the target in subject.
  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.