ES6 gives an alternative way to assign variables. Can you guess what the below code does?

ES6 gives an alternative way to assign variables. Can you guess what the below code does?

let a = 12, b = 3;
[a, b] = [b, a];
Makes both a and b equal 12.
Swaps the values inside a and b, without using extra variables.
Creates an array that contains a and b.

1 Like

Swaps the values inside a and b, without using extra variables.

2 Likes

Swaps the values inside a and b, without using extra variables.