how to switch position in array js code example
Example: how to swap two elements in an array javascript
// Before ES6
const temp = a[x]; // NOT RECOMMENDED UNLESS COMPLETELY UNAVOIDABLE
a[x] = a[y];
a[y] = temp;
// Before ES6
const temp = a[x]; // NOT RECOMMENDED UNLESS COMPLETELY UNAVOIDABLE
a[x] = a[y];
a[y] = temp;