js array elements interchanging

Is achieved by, first array direction, then the second element and third element positions interchanged countdown

var arr=new Array(10,110,34,60,52,65,18,66);
arr.reverse();
two=arr.splice(1,1,333);
three=arr.splice(-3,1,two[0]);
arr.splice(1,1,three[0]);
console.log(arr);
    

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11586711.html