1. 程式人生 > >map 數組

map 數組

meta ctype return doc cti tle div head urn

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title>map 數組</title>
</head> <body>
<script>
var data = [1, 2, 3, 4, 5];
var arr = data.map(function(val) {
//數組中冪的運算
return Math.pow(val, 3)
});
document.write(arr)
document.write("<br/>")
var qq = [‘A‘, ‘B‘, ‘C‘, ‘D‘]
var zzz = qq.map(function(val) {
//數組中的大寫換小寫
return val.toLocaleLowerCase()
})
document.write(zzz) </script>
</body>

map 數組