Skip to main content

calculateNearestIndex()

function calculateNearestIndex(values, target): number;

Finds the index of the value in values nearest to target.

Parameters

ParameterTypeDescription
valuesnumber[] | string[] | Float64Array<ArrayBufferLike>Array of numeric values.
targetstring | numberTarget value to find.

Returns

number

Index of the nearest value.