DEV Community

Discussion on: Custom exceptions with JS

Collapse
damxipo profile image
Damian Cipolat Author • Edited on

Well I'm using this way in a very massive production project and we don't lose Performance. Do you have a link that supports this or what you say or experience to tell?

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.