ฟังก์ชัน keys() ของวัตถุ typedArray คล้ายกับรายการ แต่จะส่งคืนวัตถุตัววนซ้ำที่มีดัชนีของอาร์เรย์ที่พิมพ์
ไวยากรณ์
ไวยากรณ์ของมันคือดังต่อไปนี้
typedArray.keys()
ตัวอย่าง
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
var it = int32View.keys();
for(i=0; i<int32View.length; i++) {
document.writeln(it.next().value);
}
</script>
</body>
</html> ผลลัพธ์
Contents of the typed array: 21,64,89,65,33,66,87,55 0 1 2 3 4 5 6 7