保持索引:
function clearItems (list = [], indexes = []) { indexes.forEach(index => { list[index] !== undefined && (list[index] = undefined) })}var a = [1, 2, 3, 4, 5]clearItems(a, [0, 1])console.info(a) // [undefined, undefined, 3, 4, 5]不保持索引
function clearItems (list = [], indexes = []) { indexes.sort((a, b) => b - a).forEach(index => { list.splice(index, 1) })}var a = [1, 2, 3, 4, 5, 6]clearItems(a, [0, 2, 1])console.info(a) // [4, 5, 6]


