📜  截断字符串目标 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:23.233000             🧑  作者: Mango

代码示例1
// Truncate a Stringtarget
target;
target;
// You are given two arrays and an index.
// Copy each element of the first array into the second array, in order.
// Begin inserting elements at index n of the second array.
// Return the resulting array. The input arrays should remain the same after the function runs.

function frankenSplice(arr1, arr2, n) {
    const result = [...arr2];

    result.splice(n, 0, ...arr1);

    return result;
}

frankenSplice([1, 2, 3], [4, 5, 6], 1);