Code

General Code

Spread

Spread is the opposite of rest. We take an array and spread it out. To several parameters. Here is an example… This syntax looks very similar to the rest parameter syntax. The difference is instead of just “dumping” the rest of the parameters to the function, her we are saying spread out these array entries […]

Spread Read More »

Destructuring Objects

Just like in destructuring arrays, we can also destructure objects. The syntax is slightly different using curly braces. The output would be 1 and ‘gorilla’. Notice the parentheses. We did not have those in the destructuring arrays lesson. The reason we need to put it in parentheses is due to scope. Since JavaScript uses curly

Destructuring Objects Read More »

Destructuring Arrays

In JavaScript, we can assign the values within an array to variables. Here is an example… The output will be ‘gorilla’, ‘koala’, ‘elephant’. The hint that you are destructuring is that the square brackets is on the left side of the equal sign. You can also combine destructuring with rest parameters… The output would ‘gorilla’,

Destructuring Arrays Read More »