Using 'return' instead of 'else' in JavaScript

后端 未结 13 1524
無奈伤痛
無奈伤痛 2020-12-01 14:09

I am working on a project which requires some pretty intricate JavaScript processing. This includes a lot of nested if-elses in quite a few places.

相关标签:
13条回答
  • 2020-12-01 14:49

    In many languages, is a common practice to invert if statements to reduce nesting or use preconditions.

    And having less nesting in your code improves code readability and maintainability.

    0 讨论(0)
提交回复
热议问题