TypedArray Slice() JavaScript

The Javascript TypedArray Slice() method is used to get the selected elements of the array on which is implemented.

Syntax:

Array.slice(start, end)

Parameters: start: It represents the index position where to start the selection. end: It represents the index position where to end the selection.

Returns: It returns a new array that contains the selected part of the source array.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var array = [100,200,300,400,500];  
var sliced = array.slice(1);  	 
document.write(sliced);  
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
const testArray1 = new Uint8Array([34, 12, 56, 14, 67]);
var testArray2 = testArray1.slice(1, 3);
 
document.write(testArray2);
 
</script>
</body>
</html>
Please follow and like us:
Content Protection by DMCA.com