Phương thức values() của TypedArray trả về một đối tượng iterator chứa các giá trị của mảng kiểu. Phương thức next() trả về phần tử tiếp theo trong iterator.
Cú pháp
typedArray.values()
Ví dụ
<html> <head> <title>Ví dụ JavaScript</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("Nội dung mảng kiểu: "); for(var i = 0; i < typedArray.length; i++) { document.writeln(iterator.next().value); } </script> </body> </html>
Kết quả
Nội dung mảng kiểu: 11 5 13 4 15 3 17 2 19 8