Created
September 13, 2018 11:59
-
-
Save sarfarazansari/d9a087ec3dc1dec051b6767497ba9e5e to your computer and use it in GitHub Desktop.
Revisions
-
sarfarazansari created this gist
Sep 13, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ public moveArrayPosition(arr: any[], oldPosition: number, newPosition: number) { if (newPosition >= arr.length) { let k = newPosition - arr.length + 1; while (k--) { arr.push(undefined); } } arr.splice(newPosition, 0, arr.splice(oldPosition, 1)[0]); return arr; }