Member-only story

Javascript Interview Questions: Javascript Spread Operator (ES 6)

Melih Yumak
3 min readJun 15, 2022

--

Javascript Interview Questions # 7

What is the spread operator in Javascript and how can we use the spread operators?

Hello everyone, in this tutorial we will learn about how to use spread operator in javascript with examples.

Spread operator can be used as...variableName

With the help of ES6 in the javascript we can start using destructuring.

While using destructuring we can use spread operator to

  • assign remaining values to single variable
  • Copy array or clone array
  • Combine objects to each other

How can we use spread operator?

While destructuring in the javascript arrays or objects we can pick the variables and assign the remaining ones to single variable

To be able to do that we need to use ... (spread syntax) before the variable assignment.

Lets have a look at the example below for the array destructuring with spread operator

const arrayValue = [1, 2, 3, 4];// assigning remaining elements to y with three dots
const [x, ...y] =

--

--

Melih Yumak
Melih Yumak

Written by Melih Yumak

Top Technology Writer — Lead Full Stack Software Engineer — Youtuber https://www.youtube.com/c/TechnologyandSoftware

No responses yet