course content

Course Content

Introduction to React

ES6 Spread OperatorES6 Spread Operator

The spread operator () can be easily used to assign an array's values to another array.

Changing the position of the...arr term will change the position of data in the output:

The spread operator unpacks the array arr elements and places them at the location. This can be used in many flexible ways, like passing arguments to a function:


Complete the following code by creating a new array called numbers and append the elements of both even and odd arrays (in this order) to the numbers array. Do it in a single line of code.


Fill in the gaps.

const even = [2, 4, 6, 8];
const odd = [1, 3, 5, 9];
// Write code below this line
= [,]
// White code above this line
console.log (numbers.sort ());
[1, 2, 3, 4, 5, 6, 8, 9]

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 1. Chapter 7