JavaScript 中的 TypedArray.lastIndexOf() 函数
TypedArray 对象的 lastIndexOf() 函数接受一个值并验证 typed 数组是否包含指定元素。如果是,此函数返回指定元素出现在其中的数组的索引,如果元素多次出现,此函数将返回其中最后一个索引。如果数组不包含指定元素,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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP