Learn JavaScript
Array Destructuring
34.3
Lesson

Swap variables

We can use destructuring assignment to interchange the values of two variables.

In the example given below, we are creating a temporary array to change the values.