DEV Community

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

Posted on

5 3

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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

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 "

SurveyJS custom survey software

JavaScript UI Library for Surveys and Forms

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

View demo

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay