If you are merging arrays with multiple elements into a single variable, you can use pre-defined javascript operations such as concat , push, and spread operations.
- concat operation creates a new array instead of changing existing arrays.
- push operation append/adding new element end of an array and returns the new length of the array
- spread operation [ES6] combines your arrays and returns a NEW array.
Rendered performance
Array concat getting significantly time slower than push operation. because it creates a new array and does the additional time spend to copy the first array over again and again.
Top comments (0)