TypedArray 객체의 map() 함수는 함수의 이름을 받아들이고 형식화된 배열의 모든 요소에 대해 호출하고 결과를 반환합니다.
구문
구문은 다음과 같습니다.
typedArray.map()
예시
<html>
<head>
<title>JavaScript Array every Method</title>
</head>
<body>
<script type="text/javascript">
var int32View = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);
document.write("Contents of the typed array: "+int32View);
document.write("<br>");
function square(ele) {
return ele*ele;
}
var result = int32View.map(square);
document.write("Specified element occurred at the index: "+result);
</script>
</body>
</html> 출력
Contents of the typed array: 11,5,13,4,15,3,17,2,19,8 Specified element occurred at the index: 121,25,169,16,225,9,289,4,361,64