More of a curiosity than anything.(好奇心比什么都重要。)
var inputsArray=[]; userInputs.forEach(input=>{ if(isInvert ? query.name == input.name : query.name != input.name){ inputsArray.push(input.id); } });
var inputsArray=[]; userInputs.forEach(input=>{ if(isInvert){ if (query.name == input.name){ inputsArray.push(input.id); } }else { if (query.name != input.name){ inputsArray.push(input.id); } } });
isInvert
true
isInverse
false
You can further simplify to(您可以进一步简化为)
if (isInvert == (query.name == input.name)) { inputsArray.push(input.id); }
2.1m questions
2.1m answers
60 comments
57.0k users