何か起こりたいのは、値が偽であれば、エラーだけを返すことで、それを返すことはありません。私はlodashを使用しています。 undescoreを使用して、あなたのしているので偽の値が配列に含まれている場合に返します
var jawn = [
{
"cheese" : true,
"with" : true,
"without" : true
},
{
"cheese" : true,
"with" : true,
"without" : true
},
{
"cheese" : true,
"with" : false,
"without" : true
},
{
"cheese" : true,
"with" : true,
"without" : true
}
];
_.forEach(jawn, function (item) {
if(item.with === false) {
console.log('error');
} else {
console.log('hooray');
}
});
あなただけfalsyチェックをしたい場合は、 '(item.with!)'べきか作業?あなたが何を求めているのかは分かりません。 "チーズ"、 "あり"、または "なし"のいずれかが偽であればエラーを返しますか? – CRice
'jawn.some(o =>!o.with)' –
[次へ](https://stackoverflow.com/questions/23604734/how-to-check-if-all-object-keys-has-偽値) – oneturkmen