<!doctype html>
<html>
<head>
<title>标题</title>
<meta charset="utf-8">
<script>
var arr=[1,2,3,4,5];
var evens=arr.filter(function(val){
return val%2==0;
});
var odds=arr.filter(function(val){
return val%2==1;
});
//console.log(arr);
//console.log(evens);
//console.log(odds);
var sum=
arr.reduce(function(prev,val){
return prev+val;
});
console.log(sum);
var arr2=[6,7,8,9,10];
sum=arr2.reduce(function(prev,val){
return prev+val;
},sum);
console.log(sum);
</script>
</head>
<body>
</body>
</html>
javascript面向对象(十四)
最新推荐文章于 2024-01-18 09:27:42 发布