The slice() method of the typed array object returns a portion or, chunk from the array buffer (as a separate object). It accepts two integer arguments representing the start and end of the portion of the array to be returned.
Syntax
Its Syntax is as follows
arrayBuffer.slice(3, 8)
Example
<html> <head> <title>JavaScript Array every Method</title> </head> <body> <script type="text/javascript"> var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Contents of the typed array: "+typedArray); document.write("<br>"); var resultantArray = typedArray.slice(2, 7); document.write("Resultant Array: "+resultantArray); </script> </body> </html>
Output
Contents of the typed array: 11,5,13,4,15,3,17,2,19,8 ResultantArray: 13,4,15,3,1