TypedArray의 every() 함수는 함수의 이름을 나타내는 문자열 값을 받아 배열의 모든 요소가 제공된 함수에서 구현한 테스트를 통과하는지 테스트합니다.
구문
구문은 다음과 같습니다.
typedArray.every(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.every(testResult); if(result) { document.write("all elements are above 35"); }else { document.write("all elements are not above 35"); } </script> </body> </html>
출력
Contents of the typed array: 64,89,65,21,14,66,87,55 all elements are not above 35
예시
<html> <head> <title>JavaScript Array every Method</title> </head> <body> <script type="text/javascript"> var int32View = new Int32Array([64, 89, 65, 58, 90, 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.every(testResult); if(result) { document.write("all elements are above 35"); }else { document.write("all elements are not above 35"); } </script> </body> </html>
출력
Contents of the typed array: 64,89,65,58,90,66,87,55 all elements are above 35