JavaScript中的TypedArray.includes()函数
includes()TypedArray对象的函数接受一个值,并验证此类型的数组是否包含指定的元素。如果数组包含给定元素,则返回true,否则返回false。
语法
其语法如下
typedArray.includes()
示例
<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 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
var contains = int32View.includes(66);
if(contains) {
document.write("Array contains the specified element");
}else {
document.write("Array doesn’t contains the specified element");
}
</script>
</body>
</html>输出结果
Contents of the typed array: 21,19,65,21,14,66,87,55 Array contains the specified element
示例
<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 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
var contains = int32View.includes(762);
if(contains) {
document.write("Array contains the specified element");
}else {
document.write("Array doesn’t contains the specified element");
}
</script>
</body>
</html>输出结果
Contents of the typed array: 21,19,65,21,14,66,87,55 Array doesn’t contains the specified element
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语