Spread Operator

We will learn how to extract values from objects and arrays using the spread operator.

Another great simplification has been the introduction of the spread operator (...) for objects and arrays. The use of this operator is not yet supported for objects in ES2015 because the specifics are still under discussion. However, this will change with ES2018 when it is added to the ECMAScript specification. Initially, it was added to arrays in ES2015. Using Babel, though, we can harness the power of the spread operator in our work with objects today. Many React projects make heavy use of the spread operator.

What is a spread operator?

The spread operator allows us to unpack values. Before ES2015, we had to extract arguments from an array to pass them to a function usingFunction.prototype.apply(). Let’s look at an example.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy