유형이 지정된 배열 객체의 slice() 메서드는 배열 버퍼에서 부분 또는 청크(별도의 객체로)를 반환합니다. 반환할 배열 부분의 시작과 끝을 나타내는 두 개의 정수 인수를 허용합니다.
구문
구문은 다음과 같습니다.
arrayBuffer.slice(3, 8)
예시
<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> 출력
Contents of the typed array: 11,5,13,4,15,3,17,2,19,8 ResultantArray: 13,4,15,3,1