// 模拟map,some,every等高阶函数constmap=(array, fn)=>{let results =[];for(let value of array){
results.push(fn(value));}return results
}// 测试let arr =[1,2,3,4];
arr =map(arr, v=> v *v);
console.log(arr)
constevery=(array, fn)=>{let results =true;for(let value of array){
results =fn(value);if(!results){break;}}return results;}// 测试let arr =[1,3,4,7];let r =every(arr, v=> v <10);
console.log(r)
constsome=(array, fn)=>{let results =false;for(let value of array){
results =fn(value);if(results){break;}}return results
}// 测试let arr =[1,2,5,7];let r =some(arr, v=> v >6);
console.log(r)