简体   繁体   English

Try&Catch - 你如何有效地使用它们?

[英]Try & Catch — How do you use them effectively?

I've been trying to teach myself JavaScript, and one thing I was reading on is the try/catch structure. 我一直在尝试自学JavaScript,我正在阅读的一件事是try / catch结构。 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? 有人能提供一些见解吗?

MDC try ... catch语句文档有一些你应该能够遵循的实例。

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 如果它是一个密集的功能,我不建议使用try-catch。你可以参考这个文档获得一个很好的解释: 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. 基本上,它在上下文链中创建了第二个激活对象,因此您的查找需要更多时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM