JavaScript中的TypedArray.slice()函数
slice()类型化数组对象的方法从数组缓冲区(作为单独的对象)返回一部分或块。它接受两个整数参数,分别表示要返回的数组部分的开始和结束。
语法
它的语法如下
arrayBuffer.slice(3, 8)
示例
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);
document.write("Contents of the typed array: "+typedArray);
document.write("<br>");
var resultantArray = typedArray.slice(2, 7);
document.write("Resultant Array: "+resultantArray);
</script>
</body>
</html>输出结果
Contents of the typed array: 11,5,13,4,15,3,17,2,19,8 ResultantArray: 13,4,15,3,1
热门推荐
10 航空公司祝福语简短
11 开学新人祝福语简短英语
12 长辈生日祝福语简短女性
13 顾客简短祝福语大全集
14 周年蛋糕祝福语简短英语
15 姐妹分手了祝福语简短
16 舅妈生日红包祝福语简短
17 安徽疫情祝福语简短英语
18 六一婚礼文案祝福语简短