Exercise on Destructuring
Let's try writing a few destructuring assignments and see how they simplify our code. Good luck!
We'll cover the following...
Exercise 1:
Swap two variables using one destructuring assignment.
Press + to interact
let text1 = 'swap';let text2= 'me';//Write Code here
Explanation
The text1 = text2
and the text2 = text1
assignments take place in parallel from the perspective of the whole expression. The expression on the right is evaluated, and becomes [ 'me', 'swap' ]
. This evaluation happens before interpreting the ...