Created
October 26, 2018 08:42
-
-
Save ron4stoppable/bafcaf325215e08fdcd1bd810220964f to your computer and use it in GitHub Desktop.
The function move's an element in array `arr` from index `fromIndex` to index `toIndex`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arraymove(arr, fromIndex, toIndex) { | |
var element = arr[fromIndex]; | |
arr.splice(fromIndex, 1); | |
arr.splice(toIndex, 0, element); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment