Skip to content

JSArray.LastIndexOf

boxgaming edited this page Jul 25, 2026 · 3 revisions

Returns the last index at which a given element can be found in the array, or -1 if it is not present. The array is searched backwards, starting at fromIndex.

Syntax

result% = JSArray.LastIndexOf ( a, searchElement [,fromIndex%] )

Parameters

  • The a parameter contains the native Javascript array on which the operation will be performed.
  • The searchElement parameter contains the value used for comparison.
  • The optional fromIndex% specifies the 0-based index at which to begin the search. If not specified, the search will start at the end of the array.

Example

Import JSArray From "lib/lang/array.bas"

Dim numbers As Object
numbers = JSArray.Create(5, 7, 3, 4, 2, 5, 1, 6)

Print JSArray.LastIndexOf(numbers, 5)
Print JSArray.LastIndexOf(numbers, 5, 3)

Output

5
0

See Also

JSArray.Create
JSArray.IndexOf
Javascript - Array.indexOf()

Clone this wiki locally