// How to swap two array elements in JavaScript const arr = ['a', 'b', 'c', 'e', 'd']; [arr[1], arr[0]] = [arr[0], arr[1]] console.log(arr); // Output: // [ 'b', 'a', 'c', 'e', 'd' ]