且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么更快?运行一个空函数或检查函数是否未定义?

更新时间:2023-11-08 21:13:22

  1. http://jsperf.com for more accurate benchmarking and fancy graphs. I made one: http://jsperf.com/empty-vs-check

  2. This is micro-optimization. NOBODY WILL EVER NOTICE A DIFFERENCE. There's a difference of less than a half a second for a billion iterations, which will never happen. Do what you think is more readable; don't worry about performance.