[Javascript] Swap array item in place using splice()
function swap(array, i, j) {
const [item] = array.splice(i, 1) // get item and remove this item from array
array.splice(j, 0, item)
}
function swap(array, i, j) {
const [item] = array.splice(i, 1) // get item and remove this item from array
array.splice(j, 0, item)
}