3 ms·
rest/spread is a nice bit of syntax worth using in code, but when refactoring be aware that it is not a 1:1 replacement for use of the classic JS 'arguments' bu
by kevingadd 5y ago
rest/spread is a nice bit of syntax worth using in code, but when refactoring be aware that it is not a 1:1 replacement for use of the classic JS 'arguments' builtin. They have different performance characteristics, and in particular a `Function.apply(this, arguments)` and `Function.call(this, ...args)` have different underlying implementations by spec even if they appear to do the same thing, which can mean the latter may be much much slower than you expect, potentially triggering additional garbage collections. I've had to flag this in code review a couple times :(
- leeoniya 5y agofor high perf code, i've found Object.assign() to be significantly faster than spread *. it also invoke getters, whereas spread does not. * this statement will self-invalidate in 180 days.
- eurasiantiger 5y agoSo you’re p<0.05 sure that it’s faster?