let arr = [ { "code": "F", "count": 1 }, { "code": "W", "count": 0 }, { "code": "E", "count": 0 }, { "code": "N", "count": 0 }, { "code": "C", "count": 1 } ] let ww = arr.find(ele => ele.code == 'W') let ee = arr.find(ele => ele.code == 'E') let nn = arr.find(ele => ele.code == 'N') if (ww.count === 0 && nn.count === 0) { if (ee.count === 0) { console.log('ww nn 为0时,ee不能为0') } } if (ee.count === 0) { if (ww.count === 0 || nn.count === 0) { console.log('ee为0时,ww nn不能为0') } }