DEV Community

Cover image for JavaScript ES6 - Spread Operator
Dev-Coder
Dev-Coder

Posted on

JavaScript ES6 - Spread Operator

  • 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.

Top comments (2)

Collapse
 
kmistele profile image
Kyle Mistele

cool!

Collapse
 
dev_coder profile image
Dev-Coder

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