我made a small test on jsPerf。爲什麼Math.pow更快,然後緩存Math.pow(var pow = Math.pow)
爲什麼簡單的Math.pow
然後高速緩存Math.pow (var pow = Math.pow)
?
我made a small test on jsPerf。爲什麼Math.pow更快,然後緩存Math.pow(var pow = Math.pow)
爲什麼簡單的Math.pow
然後高速緩存Math.pow (var pow = Math.pow)
?
這可能更好地發佈爲評論而不是答案。 (這是你的第一篇文章,但我不會標誌或downvote。) –
這實際上是有道理的。 +1。 –
某些查找比其他查找更便宜。 –
編譯器可能正在優化內置函數。 – Barmar
對我來說(Firefox 23)緩存的更快。 – Broxzier