React: Building Modern Web Applications
by Jonathan Hayward, Artemij Fedosejev, Narayan Prusty, Adam Horton, Ryan Vice, Ethan Holmes, Tom Bray
The spread operator
A spread operator is represented by the "…" token. A spread operator splits an iterable object into the individual values.
Note
An iterable is an object that contains a group of values, and implements ES6 iterable protocol to let us iterate through its values. An array is an example of built in an iterable object.
A spread operator can be placed wherever multiple function arguments or multiple elements (for array literals) are expected in code.
The spread operator is commonly used to spread the values of an iterable object into the arguments of a function. Let's take an example of an array and see how to split it into the arguments of a function.
Before ES6, for providing the values of an array as function argument, the programmers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access