原生方法:
//移动数组内部元素位置
function move(arr1,from,to){
if (from <0 ||to >= arr1.length){
console.error('参数错误');
return;
}
const newArr=[...arr1];
let item=newArr.splice(from,1);//删除一个数组,并返回删除的数组
newArr.splice(to,0,...item);
return newArr;
}
let arr1=['a','b','c','d'];
console.table(move(arr1,1,3))