ฟังก์ชัน forEach() ของวัตถุ TypedArray ยอมรับค่าสตริงที่แสดงชื่อของฟังก์ชันและดำเนินการตามแต่ละองค์ประกอบในอาร์เรย์
ไวยากรณ์
ไวยากรณ์ของมันคือดังต่อไปนี้
typedArray.forEach()
ตัวอย่าง
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([21, 19, 65,21, 14, 66, 87, 55 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
document.write("Result: ");
function testResult(element, index, array) {
document.writeln(element+100);
}
int32View.forEach(testResult);
//document.write("Result: "+result);
</script>
</body>
</html> ผลลัพธ์
Contents of the typed array: 21,19,65,21,14,66,87,55 Result: 121 119 165 121 114 166 187 155