1 Star 0 Fork 84

周儒浩/前端77

forked from 万少/前端77 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
19-数组方法every.html 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
万少 提交于 2022-05-13 17:59 . 数组方法-every空数组
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no"
/>
<title>19-数组方法every.html</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
</style>
</head>
<body>
<script>
// every 检测数值元素的每个元素是否都符合条件 全部都符合 返回 true 否则就返回false
// const names = ['黄圣飞', '梁聪', '王锦双', '韦嘉敏', '刘雅琴'];
// // 判断一下 上面所有同学的名称 是不是 长度 都是大于2
// const result = names.every(function (value) {
// console.log(value);
// if (value.length > 2) {
// return true;
// } else {
// return false;
// }
// });
// const result2 = names.every((v) => v.length > 2);
// console.log(result);
// every 对于空数组 也会直接返回true
const arr = [];
const result = arr.every((v) => false);
console.log(result);
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhou-ruhao77/front-end-77.git
git@gitee.com:zhou-ruhao77/front-end-77.git
zhou-ruhao77
front-end-77
前端77
js高级第1天

搜索帮助