当前位置:网站首页>数组every和some方法的区别?
数组every和some方法的区别?
2022-07-31 07:34:00 【小智玩前端】
every:返回的是一个布尔类型的值,数组中所有成员满足条件才会返回true,否则为false;
let arr = [1, 2, 3, 4, "你好"]
let res = arr.every(item => {
return typeof item == 'number'
})
console.log(res); // false
some:返回的也是布尔类型,数组中只要有一个满足,则返回true,全部不满足返回false;
let arr = [1, 2, 3, 4, "你好"]
let res = arr.some(item => {
return typeof item == 'string'
})
console.log(res); // true
边栏推荐
- 48页智慧城市规划蓝图 解决方案
- Read Elephant Swap in one article, why does it bring such a high premium to ePLATO?
- 信息收集-DNS
- 'vite' is not an internal or external command, nor is it a runnable program or batch file.
- 2022.07.14_Daily Question
- 2022.07.15_Daily Question
- 日志导致线程Block的这些坑,你不得不防
- 客户端navicat安装教程
- 2022.07.29_Daily Question
- Ceph single node deployment
猜你喜欢
MySQL 8.0.29 解压版安装教程(亲测有效)
SQL 嵌套 N 层太长太难写怎么办?
TypeError The view function did not return a valid response. The function either returned None 的解决
Vulkan与OpenGL对比——Vulkan的全新渲染架构
DAY18:Xss 靶场通关手册
mysql安装教程【安装版】
Install the deployment kubernetes KubeSphere management
Read Elephant Swap in one article, why does it bring such a high premium to ePLATO?
R语言 第一部分
使用MySQL如何查询一年中每月的记录数
随机推荐
[PSQL] Complex query
The Perfect Guide|How to use ODBC for Agentless Oracle Database Monitoring?
Chapter 9 Exceptions try...except...else...finally
[PSQL] SQL Basic Course Reading Notes (Chapter1-4)
【C#】说说 C# 9 新特性的实际运用
[Interview: Concurrency 37: Multithreading: Thread Pool] Custom Thread Pool
DAY18:Xss 靶场通关手册
2022.07.22 _ a day
客户端navicat安装教程
Tasks and task switching
安装部署KubeSphere管理kubernetes
循环结构--for循环
Vscode: Project-tree plugin
力扣 593. 有效的正方形
mysql安装教程【安装版】
报销流程|By天放师兄
最大似然估计和最小二乘法 含代码
Shellshock
初识NK-RTU980开发板
一文搞定代码中的命名