values()TypedArray的函数返回一个迭代器对象,该对象保存类型化数组的值。该next()方法返回迭代器对象中的下一个元素。
其语法如下
typedArray.values()
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);
var iterator = typedArray.values();
document.write("Contents of the typed array: ");
for(i=0; i<typedArray.length; i++) {
document.writeln(iterator.next().value);
}
</script>
</body>
</html>输出结果
Contents of the typed array: 11 5 13 4 15 3 17 2 19 8