检查数组元素是否在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 新房祝福语简短10字
14 长辈新年祝福语大全简短
15 新年给大家简短祝福语
16 生日祝福语简短独特姑姑
17 芭比的婚礼祝福语简短
18 邀请新人祝福语简短英文