📅  最后修改于: 2022-03-11 15:02:01.755000             🧑  作者: Mango
// 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' ]