在JavaScript中使用try-catch [英] Use of try-catch in JavaScript
本文介绍了在JavaScript中使用try-catch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在JavaScript中使用尝试
/ catch
的时间是多少?我有一个应用程序,我在一个被称为几百次的函数中使用它。现在我担心,尝试
/ catch
语句需要花费太多时间,应用程序将花费更长时间比没有它。
How time-intensive is the use of try
/catch
in JavaScript? I have an application and I am using it in a function which is called a few hundred times. Now I am afraid, that the try
/catch
statement is taking too much time and the application will take a lot longer than without it.
推荐答案
对jsPref有一些不错的测试:
There are some nice tests on jsPref:
- http://jsperf.com/try-catch-performance-开销
- http:// jsperf .com / try-catch-versus-massive-if
- http://jsperf.com/try-catch-002
- http://jsperf.com/try-catch-performance-overhead
- http://jsperf.com/try-catch-versus-massive-if
- http://jsperf.com/try-catch-002
结论:关于专业浏览器,null到最小差异。
这篇关于在JavaScript中使用try-catch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文