Using 'return' instead of 'else' in JavaScript

后端 未结 13 1751
無奈伤痛
無奈伤痛 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:27

    Maybe slightly, but I don't think it will be measurable unless the rest of the function involves "heavy" (and otherwise redundant since I assume that a return would give same result) js calls.

    As a side note, I think this is unnecessary micro optimization, and you should probably look elsewhere for performance improvements, ie profile the script through Chrome's developer tools or Firebug for Firefox (or similar tools) and look for slow/long running calls/functions.

提交回复
热议问题