Tukar elemen pertama dan terakhir dalam array javascript
const array = [1, 2, 3, 4, 5];
const tmp = array.pop(); //[1, 2, 3, 4]
array.push(array[0]); //[1, 2, 3, 4, 1]
array[0] = tmp; //[5, 2, 3, 4, 1]
Lander Van laer