qappleh / Interview

我是追梦赤子心,公众号「深圳湾码农」的作者,某上市集团公司高级前端开发,深耕前端领域多年,每天攻破一道题,带你从0到1系统构建web全栈完整的知识体系!
https://github.com/qappleh/Interview
1.14k stars 95 forks source link

Day369:js数组some()和every()方法的区别及自己去实现这两个方法? #372

Open qappleh opened 3 years ago

qappleh commented 3 years ago

共同点: 1.每一项的遍历数组

2.三个参数相同

3.返回的值都是布尔值

区别: 1.some()方法,遍历数组中的每一项,若其中一项为true,则返回值是true

2.every()方法,遍历数组每一项,若全部为true,才返回true ,否则返回false