开发者

Try & Catch — How do you use them effectively?

开发者 https://www.devze.com 2022-12-27 02:58 出处:网络
I\'ve been trying to teach myself JavaScript, and one thing I was reading on is the try/catch structure.Unfortunately, the tutor开发者_运维百科ial doesn\'t provide much explanation on how it would be

I've been trying to teach myself JavaScript, and one thing I was reading on is the try/catch structure. Unfortunately, the tutor开发者_运维百科ial doesn't provide much explanation on how it would be useful, just how to set it up. Can anyone offer some insight?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消