TypedArray 객체의 lastIndexOf() 함수는 값을 받아들이고 형식화된 배열에 지정된 요소가 포함되어 있는지 확인합니다. 그렇다면 이 함수는 지정된 요소가 발견된 배열의 인덱스를 반환하고 요소가 여러 번 발생한 경우 이 함수는 그 중 마지막 인덱스를 반환합니다. 배열에 지정된 요소가 포함되어 있지 않으면 indexOf() 함수는 -1을 반환합니다.
구문
구문은 다음과 같습니다.
typedArray.lastIndexOf(50)
예시
<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> 출력
Contents of the typed array: 21,19,65,21,14,66,87,55,66,97,66 Specified element occurred at the index: 10