swap array values js code example
Example 1: how to swap two elements in an array js
// Since ES6
[a[0], a[1]] = [a[1], a[0]]
Example 2: javascript switch items in array
var b = list[y];
list[y] = list[x];
list[x] = b;
// Since ES6
[a[0], a[1]] = [a[1], a[0]]
var b = list[y];
list[y] = list[x];
list[x] = b;