-1

when breaking out of Nested loops in javascript would it be better (as in faster, less problematic, or more popular) to break using a try-catch-throw like a lot of people do in python, or have a self-executing function that returns out of the loops?

Jim Jones
  • 2,568
  • 6
  • 26
  • 43

1 Answers1

3

You should use throw if you encounter a problem that means you cannot continue.

Use return to indicate you want to exit the function.

Using errors in place of control flow gives the wrong impression about your intent.

Fenton
  • 241,084
  • 71
  • 387
  • 401