ESLint error no-unneeded-ternary

前端 未结 2 1370
悲哀的现实
悲哀的现实 2021-02-11 20:25

ESLint is telling me this error message inside my JS module: error no-unneeded-ternary Unnecessary use of conditional expression for default assignment

2条回答
  •  误落风尘
    2021-02-11 21:02

    // Bad
    foo(bar ? bar : 1);
    
    // Good
    foo(bar || 1);
    

    This is how they say in Es-lint

提交回复
热议问题