JavaScript中的TypedArray.map()函数
map()TypedArray对象的函数接受函数名称,并在类型数组的每个元素上调用它,然后返回结果。
语法
其语法如下
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
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短