map的用法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>map的用法</title>
</head>
<body>
<p id="demo"></p>
<script>
var numbers = [4,9,16,25];
function myFunc(){
var demo = document.getElementById('demo');
demo.innerHTML = numbers.map(Math.sqrt);//2,3,4,5
}
// myFunc();
var demo = document.getElementById('demo');
numbers.map(
function (item,index,arr){
arr[index] = item*item;
demo.innerHTML = arr;
}
);
</script>
</body>
</html>