JavaScript typedArray.lastIndexOf() Method Last Updated : 10 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The typedArray.lastIndexOf() is an inbuilt function in JavaScript which is used to return the last index of the typedArray at which a given element is present otherwise it returns -1 if the element is not present. Syntax: typedArray.lastIndexOf(search_Element, from_Index]) Parameters: It accepts two parameters which are specified below: search_Element: It is the element whose last index is to be searched.from_Index: It is optional. It is the index up to which an element is to be searched and its default value is the length of the typedArray. Return value: It returns the last index of the typedArray at which a given element is present otherwise it returns -1 if the element is not present. Example 1: javascript // Creating a typedArray with some elements var A = new Uint8Array([5, 10, 15, 15, 5, 20, 10]); // Calling lastIndexOf() function b = A.lastIndexOf(10); c = A.lastIndexOf(5); d = A.lastIndexOf(15); e = A.lastIndexOf(); f = A.lastIndexOf(20); g = A.lastIndexOf(25); // Printing returned values console.log(b); console.log(c); console.log(d); console.log(e); console.log(f); console.log(g); Output: 6 4 3 -1 5 -1 Example 2: javascript // Creating a typedArray with some elements var A = new Uint8Array([5, 10, 15, 15, 5, 20, 10]); // Calling lastIndexOf() function b = A.lastIndexOf(10, 1); c = A.lastIndexOf(5, 2); d = A.lastIndexOf(15, 3); e = A.lastIndexOf(15, 1); f = A.lastIndexOf(20, 1); g = A.lastIndexOf(25, 3); // Printing returned values console.log(b); console.log(c); console.log(d); console.log(e); console.log(f); console.log(g); Output: 1 0 3 -1 -1 -1 Comment More infoAdvertise with us Next Article JavaScript typedArray.indexOf() Method K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies javascript-typedArray JavaScript-Methods Similar Reads JavaScript Array lastIndexOf() Method The JavaScript Array lastIndexOf() Method is used to find the index of the last occurrence of the search element provided as the argument to the function.Syntax: array.lastIndexOf(element, start)Parameters: This method accepts two parameters as mentioned above and described below: element: This para 3 min read JavaScript typedArray.indexOf() Method The typedArray.indexOf() is an inbuilt function in JavaScript which is used to return the index of the element if found in the given typedArray otherwise it returns -1. Syntax: typedarray.indexOf(Element, Index); Parameters: It accepts two parameter which are specified below- Element: It is the elem 2 min read TypeScript Array lastIndexOf() Method The Array.prototype.lastIndexOf() method in TypeScript is used to find the last index at which a given element can be found in the array, searching backwards from the fromIndex. It returns the index of the found element, or -1 if the element is not present.Syntax:array.lastIndexOf(searchElement[, fr 2 min read JavaScript TypedArray.prototype.findLast() Method A new method, TypedArray.prototype.findLast(), was introduced in ECMAScript 2023 (ES2023). The method findLast() of instances TypedArray proceeds traverse over the typed array backwards and provides method returning the value of the first element that satisfies the supplied testing function. When th 2 min read JavaScript TypedArray.prototype.findIndex() Method Method TypedArray.prototype.findIndex() of JavaScript returns the index of the first element in the typed array that fulfils the conditions specified by the testing function, if no elements satisfy it, -1 is returned, the findIndex() method takes a callback function as an argument and it returns an 2 min read TypeScript | String lastIndexOf() Method The lastIndexOf() is an inbuilt function in TypeScript which is used to get the index within the calling String object of the last occurrence of the specified value. Syntax: string.lastIndexOf(searchValue[, fromIndex]) Parameter: This method accepts two parameter as mentioned above and described bel 1 min read Like