JavaScript性能:调用vs Apply [英] JavaScript performance: Call vs Apply
本文介绍了JavaScript性能:调用vs Apply的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 func.apply(obj,params)
切换到 func.call(obj)$ c $是否有性能优势c>当
params
是一个空数组或 null
?
Is there a performance benefit in switching from func.apply(obj, params)
to func.call(obj)
when params
is an empty array or null
?
我的意思是,调用 func.call(obj)
比调用 func.apply(obj,null)更快
?
I mean, is calling func.call(obj)
any faster than calling func.apply(obj, null)
?
我最感兴趣的是NodeJS 4.x下的性能。
I'm mostly interested in performance under NodeJS 4.x.
这是一个算法必须进行大量此类调用。
This is for an algorithm that has to make a lot of such calls.
推荐答案
在此页面上进行比较。 https://jsperf.com/call-apply-segu
通话速度更快我的机器。
On this page there is a comparison. https://jsperf.com/call-apply-segu Call was faster on my machine.
这篇关于JavaScript性能:调用vs Apply的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文