TypedArray의 filter() 함수는 함수의 이름을 나타내는 문자열 값을 받아들이고, 배열의 모든 요소가 제공된 함수에 의해 구현된 테스트를 통과하는지 테스트하고, 테스트를 통과한 모든 요소로 새 배열을 만듭니다.
구문
구문은 다음과 같습니다.
typedArray.filter(function_name)
예시
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([64, 89, 65,21, 14, 66, 87, 55 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
function testResult(element, index, array) {
var ele = element>35
return ele;
}
result = int32View.filter(testResult);
document.write("Elements that are greater than 35: "+result);
</script>
</body>
</html> 출력
Contents of the typed array: 64,89,65,21,14,66,87,55 Elements that are greater than 35: 64,89,65,66,87,55