Swap Array Elements Inline
Array destructuring also works for index references to arrays. In this case, you basically tell the runtime the following:
Take the value at array and place it inside array, and then take the value at array and place it at array, while implicitly creating a temporary variable because you don’t want to lose the original values.
The runtime creates the temporary variable automatically for you, under the hood, so you don’t have to deal with it in your code.
Without array destructuring, your code would look like this: