Hàm lastIndexOf() của TypedArray tìm kiếm một giá trị từ cuối mảng về đầu, trả về chỉ số của lần xuất hiện cuối cùng. Trả về -1 nếu không tìm thấy. Tìm kiếm dùng so sánh nghiêm ngặt (===).
Cú pháp
Cú pháp của nó như sau:
typedArray.lastIndexOf(searchElement[, fromIndex])
Ví dụ
<html> <head> <title>Ví dụ JavaScript TypedArray lastIndexOf</title> </head> <body> <script type="text/javascript"> var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55, 66, 97, 66]); document.write("Nội dung mảng typed: "+int32View); document.write("<br>"); var contains = int32View.lastIndexOf(66); document.write("Phần tử xuất hiện cuối tại chỉ số: "+contains); </script> </body> </html>
Kết quả
Nội dung mảng typed: 21,19,65,21,14,66,87,55,66,97,66 Phần tử xuất hiện cuối tại chỉ số: 10