how to fix jslint The '&&' subexpression should be wrapped in parens error

前端 未结 3 1144
误落风尘
误落风尘 2021-01-06 06:20

I put everything in parentheses but code below still throws error in jslint:

Problem at line 5 character 104: The \'&&\' subexpression should be wrap         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 06:56

    It's complaining about the form if(a && b && c || d) because (I suppose) it's not immediately obvious whether && or || will take precedence. Fix it to look like if(a && b && (c || d)) and it will stop complaining.

提交回复
热议问题