JSFiddle - React, Tailwind, and code Playground

by cmruser

JavaScript

var a = [{a:'a', b:2, c:true}, {a:'b', b:3, c:true}, {a:'a1', b:3, c:false}];


Array.prototype.move = function (old_index, new_index) {
    if (new_index >= this.length) {
        var k = new_index - this.length;
        while ((k--) + 1) {
            this.push(undefined);
        }
    }
    this.splice(new_index, 0, this.splice(old_index, 1)[0]);
  };
console.log(a[0]);
a.move(0,2);
console.log(a[0]);