Created
May 14, 2018 02:50
-
-
Save mdimai666/463c17b2cc807605df7d3178a6aede46 to your computer and use it in GitHub Desktop.
This file contains 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 array_move(arr, old_index, new_index) { | |
if (new_index >= arr.length) { | |
var k = new_index - arr.length + 1; | |
while (k--) { | |
arr.push(undefined); | |
} | |
} | |
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]); | |
return arr; // for testing | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment