Quick benchmark for merge two arrays with immutable state
var compare = () => {
var a = _.range(0, 1000000)
var b = _.range(1000000, 2000000)
console.time('spread')
var c = [...a, ...b]
console.timeEnd('spread')
console.time('concat')
var d = [].concat(a, b)
console.timeEnd('concat')
console.time('concat with a')
var e = a.concat(b)
console.timeEnd('concat with a')
console.time('concat prototype')
var f = Array.prototype.concat(a, b)
console.timeEnd('concat prototype')
console.time('concat prototype with empty array')
var g = Array.prototype.concat([], a, b)
console.timeEnd('concat prototype with empty array')
}
spread: 190.30029296875ms
concat: 10.664794921875ms
concat with a: 11.88818359375ms
concat prototype: 20.571044921875ms
concat prototype with empty array: 20.703125ms
spread: 29.738ms
concat: 48.883ms
concat with a: 16.941ms
concat prototype: 24.157ms
concat prototype with empty array: 24.755ms
spread: 151.183ms
concat: 12.076ms
concat with a: 13.202ms
concat prototype: 26.343ms
concat prototype with empty array: 29.401ms
Immutable utils for array in response with test result