I was browsing the answers to this question: Can I dispatch an action in reducer? and in this answer, I see the following:
actionQueue = actionQueue.concat([asyncAction]);
which is essentially the same as:
actionQueue.push(asyncAction);
(ignoring that the concat
call is creating a new array and re-assigning it to actionQueue
, the result is the same -- an array with asyncAction
appended to it).
Initially, I thought that it (perhaps) performed better (somehow), and someone else was apparently wondering the same as they beat me to it in jsperf: Array .concat() vs. .push().
As the results of the jsperf testing show, the concat
method is significantly slower than push
(at least as far as Chrome is concerned).
Is there something I'm missing?
Is there a reason concat
would be preferred in this use case?