Question · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects
Swapping Variable Values
How do you swap the values of two variables using array destructuring?
Answer options
- {a, b} = {b, a}
- [a, b] = [b, a]
- swap(a, b)
- a <=> b
Show the answer
Correct answer:
- [a, b] = [b, a]