Gets the index of a specified target value in a string, array or an object. Unlike Array.prototype.indexOf(), this function works for finding NaN and differentiates between -0 and 0.

This function is valid in v2.13.0 to v2.24.3. This function has been downloaded 67 times.


{Array|Object|string} subject
The array, object or string in which target should be searched for.
{*} target
The target value to search for within subject.
{number=} opt_start Optional
The position at which to start the search for strings or arrays. This will be ignored for objects. Negative values will be calculated from the end.


If subject is an array or a string this will be a integer representing the first position at which target is found within subject or this will be -1 which represents that target was not found. If subject is an object this will be key at which target was first found (based on Object.keys()) or undefined if target was not found.

Required Function

This function directly requires the following function which is included automatically:

  • typeOf()
    Either gets the type of a value or adds a constructor registering its custom type name.

Requiring Functions

This function is directly required by the following functions:

  • ifIs()
    If the first and second arguments are the same the third argument is passed back, otherwise the fourth argument (or if not given the first argument) is passed back.
  • includes()
    Determines whether or not a target is present within a given string, array or object. Unlike Array.prototype.includes(), this function differentiates between -0 and 0.
  • isKind()
    Checks to see if a value is of a specific kind.
  • keys()
    Gets the keys of a specified value.
  • uneval()
    Creates a string representation of the given object or primitive.