DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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 Author

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

Need a better mental model for async/await?

Check out this classic DEV post on the subject.

β­οΈπŸŽ€ JavaScript Visualized: Promises & Async/Await

async await