Array.lastIndexOf

lastIndexOf — Returns the last position of the element with the given value.

Description

Array.lastIndexOf([integer search, [integer offset]])

Parameters

Name Description Type Default Optional
search integer Yes
offset integer Yes

Return values

integer.

Examples

Example #1 – lastIndexOf example
var array = [2, 4, 8, 4, 16, 4, 32]; console.log(array.lastIndexOf()); // -1 console.log(array.lastIndexOf(3)); // -1 console.log(array.lastIndexOf(4)); // 5 console.log(array.lastIndexOf(4, 2)); // 1

See also

  • Array.indexOf()

External references