set()TypedArray对象的函数接受一个表示索引的数字数组,并将指定数组的内容从给定索引开始复制到当前数组中。
其语法如下
typedArray.set()
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var typedArray1 = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);
document.write("Contents of the typed array: "+typedArray1);
document.write("<br>");
var typedArray2 = new Int32Array([110, 215, 316, 916, 616, 117, 311 ]);
typedArray1.set(typedArray2, 3);
document.write("Result: "+typedArray1);
</script>
</body>
</html>输出结果
Contents of the typed array: 11,5,13,4,15,3,17,2,19,8 Result: 11,5,13,110,215,316,916,616,117,311