检查数组元素是否在JavaScript中包含错误值的方法?
要检查数组元素是否包含错误值,可以在JavaScript中使用Object.values()。以下是代码-
示例
const details = [
{
customerDetails:
[
{
isMarried: true
},
{
isMarried: true
}
]
},
{
customerDetails:
[
{
isMarried: true
},
{
isMarried: true
}
]
}
]
const isNotMarried = Object.values(details)
.some(({customerDetails})=>customerDetails.some(({isMarried})=>!isMarrie
d));
console.log(isNotMarried);要运行上述程序,您需要使用以下命令-
node fileName.js.
在这里,我的文件名为demo75.js。
输出结果
这将产生以下输出-
PS C:\Users\Amit\JavaScript-code> node demo75.js false
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志