ฟังก์ชัน subarray() ของวัตถุ TypedArray ส่งคืนส่วนของอาร์เรย์ปัจจุบัน ยอมรับตัวเลขสองตัวที่แสดงถึงจุดเริ่มต้นและจุดสิ้นสุดของอาร์เรย์ย่อย
ไวยากรณ์
ไวยากรณ์ของมันคือดังต่อไปนี้
typedArray.subarray(5, 9)
ตัวอย่าง
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var typedArray = new Int32Array([111, 56, 62, 40, 75, 36, 617, 2, 139, 827 ]);
var result = typedArray.subarray(3, 7);
document.write("Contents of the typed array: "+result);
</script>
</body>
</html> ผลลัพธ์
Contents of the typed array: 40,75,36,617