All streams
Search
Write a publication
Pull to refresh
0
0
Send message
А почему бы не попробовать Array.prototype.splice?

Перебор.

<source lang="javascript">
const swap = (array, index1, index2) => {
    array.splice(
        index2,
        1,
        array.splice(index1, 1, array[index2])[0]
    )
    return array
};

Information

Rating
Does not participate
Registered
Activity