DEV Community

loading...

Discussion on: Custom exceptions with JS

Collapse
danielpdev profile image
danielpdev

try-catch will impact your performance only if you actually throw exceptions.
Examples:

  1. Performance loss when exception is thrown: jsperf.com/try-catch-performance-jls
  2. No performance loss if no exception is thrown: jsperf.com/try-catch-performance-j...

Conclusion:
I'm not saying that you should not use try-catch at all, but like in the examples above actually throwing an exception can be easily avoided.

Thread Thread
damxipo profile image
Damian Cipolat Author

Nice, thanks for the links provides very useful information. I will be investigating about this.