Is a reversed switch statement acceptable JavaScript?

后端 未结 3 865
无人共我
无人共我 2020-12-20 19:12

JSLint is complaining that (true) is a weird condition. Which is understandable if I wasn\'t using it on a reversed switch statement. So is JSLint

3条回答
  •  渐次进展
    2020-12-20 19:30

    numberOfColumns = Math.max(4, Math.floor(menuLinksLength / 3));
    

    This will give you identical results to your existing code. Your question is fairly ambiguous, as "acceptable" is a very subjective term. I would personally reject any merge request with a reversed switch statement, because I actually can't think of a situation where that couldn't be replaced with something simpler and/or easier to read.

提交回复
热议问题