One should avoid
Recommendations in the node.js community is that you pass errors around in callbacks (Because errors only occur for asynchronous operations) as the first argument
There are also other issues like try / catch is really expensive and it's ugly and it simply doesn't work with asynchronous operations.
So since synchronous operations should not throw an error and it doesn't work with asynchronous operations, no-one uses try catch except for errors thrown by host objects or ECMAScript
|show 5 more comments|
The problem is that the control flow leaves the
I believe that much of the reason that
Some of the major issues in other languages that cause exceptions to occur simply don't exist in JS. Type casting isn't needed the vast majority of the time. Instead, the preferred method is typically to feature check (enforcing a particular interface):