every是判断数组中所有元素均满足某个条件,some是判断数组中任意一个元素满足条件
举个栗子:
const arr1 = [{name:'谭',},{name:'谭'},{name:'高'}];
const arr2 = [{name:'谭',},{name:'谭'},{name:'谭'}];const result1 = arr1.every(item => item.name === '谭');const result2 = arr2.every(item => item.name === '谭');const result3 = arr1.some(item => item.name === '高');const result4 = arr2.some(item => item.name === '高');console.log('result1输出结果---->',result1);console.log('result2输出结果---->',result2);console.log('result3输出结果---->',result3);console.log('result4输出结果---->',result4);
输出结果: