使用时间有多密集try
/catch
在 JavaScript 中?我有一个应用程序,我在一个被调用数百次的函数中使用它。现在我担心的是,try
/catch
声明花费了太多时间,并且应用程序将比没有声明花费更长的时间。
jsPref 有一些不错的测试:
- http://jsperf.com/try-catch-performance-overhead http://jsperf.com/try-catch-performance-overhead
- http://jsperf.com/try-catch-versus-massive-if http://jsperf.com/try-catch-versus-massive-if
- http://jsperf.com/try-catch-002 http://jsperf.com/try-catch-002
结论:在主要浏览器上,差异几乎为零。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)