views:

151

answers:

3

I've been trying to teach myself JavaScript, and one thing I was reading on is the try/catch structure. Unfortunately, the tutorial doesn't provide much explanation on how it would be useful, just how to set it up. Can anyone offer some insight?

+3  A: 

MDC try...catch statement documentation has some solid examples you should be able to follow.

gnarf
A: 

This article has some general advice about when to use try...catch.

Oren
A: 

If it is a intensive function, I wouldn't recommend using try-catch.You can refer this doc for a good explanation: http://wiki.forum.nokia.com/index.php/JavaScript_Performance_Best_Practices#Don.27t_use_try-catch-finally_inside_performance-critical_functions

Basically, It creates a second activation object in the context chain and hence your lookups take more time.

Rajat