What is faster: try catch vs Promise

后端 未结 3 573
野性不改
野性不改 2020-12-16 01:11

I heard such an opinion that you should avoid usage of try/catch at all because it takes many resources. So could the promise error handling to be faster? Or it does not mat

3条回答
  •  长情又很酷
    2020-12-16 01:39

    Based on this benchmark i found it doesn't seem like most applications performance would be affected by such decision.

    https://jsperf.com/try-catch-vs-promise

    NOTE: try/catch does work with asynchronous code at least when using "async/await"!

提交回复
热议问题