DEV Community

loading...
Cover image for JavaScript ES6 - Spread Operator

JavaScript ES6 - Spread Operator

dev_coder profile image Dev-Coder ・1 min read
  • ES6 provides a new operator called spread operator that consists of three dots (...).
  • The spread operator allows you to spread out elements of an iterable object such as an array,a map, or a set.

Example
Alt Text

Result
Alt Text

  • Above example, the three dots (...) located in front of the oddValue and evenValue array is the spread operator.
  • The spread operator unpacks the elements of the oddValue and evenValue array.

Summary

  • The spread operator is denoted by three dots (…).
  • The spread operator unpacks elements of iterable objects such as arrays, sets, and maps into a list.
  • The spread operator can be used to clone an iterable object or merge iterable objects into one.

Discussion (2)

pic
Editor guide
Collapse
kmistele profile image
Collapse
dev_coder profile image
Dev-Coder Author

Thank You! This is my first blog post.
" Congratulations for @CodeLighthouse.io "