Is a reversed switch statement acceptable JavaScript?

后端 未结 3 856
无人共我
无人共我 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:39

    Personally I wouldn't like seeing reversed switch in a code base. It doesn't buy you anything when compared to a plain if/elseif block, and its exotic nature can be cause for confusion.

    That's also what JSLint is complaining about:

    You are doing something unorthodox. Is there a good reason for it? If not, it might be better to stick to the basics.

提交回复
热议问题