es6 · ES6 Basics
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];Answers
- 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.