TypedArray 객체의 included() 함수는 값을 받아들이고 이 형식화된 배열에 지정된 요소가 포함되어 있는지 확인합니다. 배열에 주어진 요소가 포함되어 있으면 true를 반환하고 그렇지 않으면 false를 반환합니다.
구문
구문은 다음과 같습니다.
typedArray.includes()
예시
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
var contains = int32View.includes(66);
if(contains) {
document.write("Array contains the specified element");
}else {
document.write("Array doesn’t contains the specified element");
}
</script>
</body>
</html> 출력
Contents of the typed array: 21,19,65,21,14,66,87,55 Array contains the specified element
예시
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
var contains = int32View.includes(762);
if(contains) {
document.write("Array contains the specified element");
}else {
document.write("Array doesn’t contains the specified element");
}
</script>
</body>
</html> 출력
Contents of the typed array: 21,19,65,21,14,66,87,55 Array doesn’t contains the specified element