This function merges two arrays into one.
JavaScript:
let merge = (arr1, arr2) => [...arr1, ...arr2];
// Example
console.log(merge([1, 2, 3], [4, 5, 6])); // [1, 2, 3, 4, 5, 6]
console.log(merge(['a', 'b'], ['c', 'd'])); // ['a', 'b', 'c', 'd']
TypeScript:
let merge = (arr1: T[], arr2: T[]): T[] => [...arr1, ...arr2];
// Example
console.log(merge([1, 2, 3], [4, 5, 6])); // [1, 2, 3, 4, 5, 6]
console.log(merge(['a', 'b'], ['c', 'd'])); // ['a', 'b', 'c', 'd']