Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
karthikeya Boyini

The lastIndexOf() function of the TypedArray object accepts a value and verifies whether the typed array contains the specified element. If so, this function returns the index of the array at which the specified element found, if the element occurred multiple timed this function returns the last index among them. If the array doesn’t contain the specified element the indexOf() function returns -1.

Syntax

Its Syntax is as follows

typedArray.lastIndexOf(50)

Example

Live Demo

<html>
   <head>
      <title>JavaScript Array every Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55, 66, 97, 66 ]);
         document.write("Contents of the typed array: "+int32View);
         document.write("<br>");
         var contains = int32View.lastIndexOf(66);
         document.write("Specified element occurred at the index: "+contains);
      </script>
   </body>
</html>

Output

Contents of the typed array: 21,19,65,21,14,66,87,55,66,97,66
Specified element occurred at the index: 10

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.