Use of try-catch in JavaScript

前端 未结 4 462
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 15:26

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. N

4条回答
  •  佛祖请我去吃肉
    2021-02-05 15:39

    There are some nice tests on jsPref:

    • http://jsperf.com/try-catch-performance-overhead
    • http://jsperf.com/try-catch-versus-massive-if
    • http://jsperf.com/try-catch-002

    Conclusion: on the major browser, null to minimal differences.

提交回复
热议问题