Use Destructuring Assignment to Assign Variables from Arrays
Hints
Hint # 1
We have to take some precaution in this case.
- Do not try to re-declare a or b while destructuring as they are already declared in the first
let
statement.
Solutions
Solution 1 (Click to Show/Hide)
let a = 8, b = 6;
[a, b] = [b, a];