how to change index location at js code example
Example 1: moving a item fro index to another index, javascript
function arraymove(arr, fromIndex, toIndex) {
var element = arr[fromIndex];
arr.splice(fromIndex, 1);
arr.splice(toIndex, 0, element);
}
Example 2: change index array javascript
Array.prototype.move = function(from, to) {
this.splice(to, 0, this.splice(from, 1)[0]);
};