lastIndefOf

The lastIndexOf() method returns the index within the calling String object of the last occurrence of the specified value, searching backwards from fromIndex. Returns -1 if the value is not found.

Install

Install all functions of strman

yarn add strman

or just the lastIndefOf function

yarn add strman.lastindexof

Usage

import { lastIndefOf } from 'strman'
// OR
import lastIndefOf from 'strman.lastindexof'
Parameters:
Name Type Attributes Default Description
value String

The String!

needle String

Value to search.

offset Number <optional>

Offset to search.

caseSensitive Boolean <optional>
true

if you use caseSensitive to test.

Source:
Returns:

Return position of the last occurrence of 'needle'.

Type
Number
Example
const title = 'strman strman'
result = lastIndexOf(title, 'str')
// => 7