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
热门推荐
1 天仙配简短祝福语
10 结婚伴娘祝福语简短精辟
11 对转校同学祝福语简短
12 自由 生日祝福语简短独特
13 对公司年会祝福语简短
14 写给女友的祝福语++简短
15 金婚祝福语大全简短唯美
16 考上大学简短祝福语、
17 客户祝福语事业文案简短
18 客户新房祝福语简短大气