Note: it is convention to use ALL CAPS for constants, but the above is for illustrative purposes.

Destructuring

Destructuring allows you to assign values to a set of variables.

let x = 2;
let y = 3;
[x, y] = [y, x]; // x is now 3, and y is now 2

What we see on the right side of the destructuring assignment in the above example is an array built from the values that are in y and x.
However, on the left side, it is not an array, but rather the individual variables x and y surrounded by square brackets ([]) because we are destructuring an array.

In other words, in the above example we are taking the value of the variable in the first index of the array [y, x] (in this case 'y = 3') and assigning it to x, and taking the value of the variable in the second index of the array [y, x] (in this case x = 2) and assigning it to y. Thus, our variables have switched values.

Variable assignment can also be done from a function that returns an array:

You can associate a tag with a template. In this case, the tag upper is a function that is invoked.

The first parameter being passed into the upper() function is known as a parsed template string. These are the pieces of literal text in the template, chopped into an array such that the substitutions are removed. The second parameter is a rest parameter (also an array) using the values of the substitutions.

strings = ["", " + ", " is ", ""];
values = [1, 3, 4]

This shows us that there are lots of possibilities in terms of tags that take a template and encode it, tags for localization, and more.