Array.prototype.lastIndexOf() - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

converted to an integer

Zero-based index at which to start searching backwards, converted to an integer.

Finding all the occurrences of an element

The following example uses lastIndexOf to find all the indices of an element in a given array, using push() to add them to another array as they are found.

Finding all the occurrences of an element

The following example uses lastIndexOf to find all the indices of an element in a given array, using push() to add them to another array as they are found.

Indexed collections

Array.prototype.findIndex()

Array.prototype.findLastIndex()

TypedArray.prototype.lastIndexOf()

String.prototype.lastIndexOf()

Learn how to contribute

This page was last modified on Jul 10, 2025 by MDN contributors.

[Symbol.iterator]()

[Symbol.unscopables]

[Symbol.hasInstance]()

__defineGetter__()

__defineSetter__()

__lookupGetter__()

__lookupSetter__()