JavaScript · Junior · Question 61 of 75

What does [a, b] = [b, a] do?

Explanation

The right side creates a temporary array, then destructuring assigns its elements. If the previous line has no semicolon, it may be parsed as an index access - another reason to use semicolons or a linter.

Further reading

Problem with a question

JavaScript · Junior · question 61

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz