src/util/Util.js
/**
  * Get the index in the input array of the first element that matches the given value.
  *
  * <p> Note: index is able to handle NaN, null, as well as any value convertible to a JSON string.</p>
  *
  * @name module:util.index
  * @function
  * @public
  * @param {array} input the input array
  * @param {Number|string|object|null} value the matching value
  * @returns the index of the first element that matches the value
  * @throws if the input array does not contain any matching element
  */
Get the index in the input array of the first element that matches the given value.
 Note: index is able to handle NaN, null, as well as any value convertible to a JSON string.


Get the index in the input array of the first element that matches the given value . Note : index is able to handle NaN null as well as any value convertible to a JSON string .
function index(input, value)
{
	const response = {
		origin: "util.index",
		context: "when getting the index in the input array of the first element that matches the given value",
	};
	try
	{
		if (!Array.isArray(input))
		{
			throw "the input argument should be an array";
		}
		const match = _match(value);
		const index = input.findIndex(match);
		if (index === -1)
		{
			throw "no element in the input array matches the value";
		}
		return index;
	}
	catch (error)
	{
		throw { ...response, error };
	}
}
function index ( input , value ) { const response = { origin : "util.index" , context : "when getting the index in the input array of the first element that matches the given value" , } ; try { if ( ! Array . isArray ( input ) ) { throw "the input argument should be an array" ; } const match = _match ( value ) ; const index = input . findIndex ( match ) ; if ( index === - 1 ) { throw "no element in the input array matches the value" ; } return index ; } catch ( error ) { throw { ... response , error } ; } }
Get the index in the input array of the first element that matches the given value.
Get the index in the input array of the first element that matches the given value .