Generates a new array by merging arrays and values without modifying the originals.
Asked in frontend interviews at Amazon, ByteDance and Apple