Hàm keys() của TypedArray trả về một đối tượng Iterator mới chứa các chỉ số (indices) của mảng: 0, 1, 2, ..., length-1.
Cú pháp
Cú pháp của nó như sau:
typedArray.keys()
Ví dụ
<html> <head> <title>Ví dụ JavaScript TypedArray keys</title> </head> <body> <script type="text/javascript"> var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55]); document.write("Nội dung mảng typed: "+int32View); document.write("<br>"); var it = int32View.keys(); for(let i = 0; i < int32View.length; i++) { document.write(it.next().value); document.write(" "); } </script> </body> </html>
Kết quả
Nội dung mảng typed: 21,64,89,65,33,66,87,55 0 1 2 3 4 5 6 7