# Function upperBound

• Find the index of the first element which compares `>` than a value.

#### Parameters

• ##### array: ArrayLike<T>

The sorted array-like object to search.

• ##### value: U

The value to locate in the array.

• ##### fn: ((element, value) => number)

The 3-way comparison function to apply to the values. It should return `< 0` if an element is less than a value, `0` if an element is equal to a value, or `> 0` if an element is greater than a value.

• (element, value): number

#### Returns number

• ##### start: number = 0

The index of the first element in the range to be searched, inclusive. The default value is `0`. Negative values are taken as an offset from the end of the array.

• ##### stop: number = -1

The index of the last element in the range to be searched, inclusive. The default value is `-1`. Negative values are taken as an offset from the end of the array.

#### Returns number

The index of the first element which compares `>` than the value, or `length` if there is no such element. If the computed index for `stop` is less than `start`, then the computed index for `start` is returned.

#### Notes

The array must already be sorted in ascending order according to the comparison function.

Logarithmic.

#### Undefined Behavior

Searching a range which is not sorted in ascending order.

A `start` or `stop` which is non-integral.

Modifying the length of the array while searching.

#### Example

``````import { ArrayExt } from '@lumino/algorithm';function numberCmp(a: number, b: number): number {  return a - b;}let data = [0, 3, 4, 7, 7, 9];ArrayExt.upperBound(data, 0, numberCmp);   // 1ArrayExt.upperBound(data, 6, numberCmp);   // 3ArrayExt.upperBound(data, 7, numberCmp);   // 5ArrayExt.upperBound(data, -1, numberCmp);  // 0ArrayExt.upperBound(data, 10, numberCmp);  // 6
``````

Generated using TypeDoc