🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Spread_syntax
Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
May 22, 2026 - The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-spread-operator
JavaScript Spread Operator - GeeksforGeeks
The spread operator (...) in JavaScript provides a simple and expressive way to expand elements from arrays, strings, or objects. It helps make code cleaner by reducing the need for manual copying or looping.
Published   January 16, 2026
🌐
DEV Community
dev.to › marinamosti › understanding-the-spread-operator-in-javascript-485j
Understanding the Spread Operator in JavaScript - DEV Community
September 23, 2019 - The spread operator is an ES6 feature, and thus is not supported in every browser (IE strikes again). However you can rest assured that it will work on all major and modern browsers. Browser Compatibility ... Spread syntax allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-spread-and-rest-operators
JavaScript Spread and Rest Operators – Explained with Code Examples
February 8, 2024 - The spread operator, denoted by three consecutive dots (...), is primarily used for expanding iterables like arrays into individual elements.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › javascript spread operator
The Practical Usages of JavaScript Spread Operator
May 8, 2024 - If you want to pass an array to the push() method, you need to use apply() method as follows: let rivers = ['Nile', 'Ganges', 'Yangte']; let moreRivers = ['Danube', 'Amazon']; [].push.apply(rivers, moreRivers); console.log(rivers);Code language: JavaScript (javascript) This solution looks verbose. The following example uses the spread operator to improve the readability of the code:
🌐
Programiz
programiz.com › javascript › spread-operator
JavaScript Spread Operator
The JavaScript spread operator ... is used to expand or spread out elements of an iterable, such as an array, string, or object. This makes it incredibly useful for tasks like combining arrays, passing elements to functions as separate arguments, or even copying arrays. Here's a quick example of ...
🌐
Medium
cleverzone.medium.com › demystifying-javascript-spread-operat-71924c888a8
Demystifying JavaScript : Spread operator (…) | by Abhijeet Kumar | Medium
August 26, 2023 - Although the spread and rest operators share a similar syntax (...), they serve different purposes in JavaScript. Understanding this distinction is essential for effectively utilizing both operators in your code. The spread operator is used to spread array values or iterables into a new array or object.
🌐
W3Schools
w3schools.com › howto › howto_js_spread_operator.asp
How To Use the Spread Operator (...) in JavaScript
The JavaScript spread operator (...) expands an iterable (like an array) into more elements.
🌐
GPTWebHelper
blixtdev.com › how-to-use-the-spread-operator-in-javascript
How to Use The Spread Operator in JavaScript
December 20, 2022 - In this simple example, we destructure a 5 element array into 3 variables: the first value is assigned to a, the second value is assigned to b, and the remainder of the list is assigned to rest:
Find elsewhere
🌐
SamanthaMing
samanthaming.com › tidbits › 92-6-use-cases-of-spread-with-array
6 Use Case of Spread with Array in JavaScript | SamanthaMing.com
The spread syntax takes your array and expands it into elements. Imagine your array is like those Russian Dolls.
🌐
Mimo
mimo.org › glossary › javascript › spread-operator
JavaScript Spread Operator: Syntax, Usage, and Examples
The spread operator (...) lets you expand arrays, objects, or strings into individual values. You’ll use it a lot when copying data, merging values, or passing items into functions. The spread operator looks the same everywhere, three dots: ...value. What changes is the context around it. ... Become a full-stack developer. Learn HTML, CSS, JavaScript, and React as well as NodeJS, Express, and SQL
🌐
W3Schools
w3schools.com › react › react_es6_spread.asp
React ES6 Spread Operator
The JavaScript spread operator (...) copies all or part of an existing array or object into another array or object.
🌐
Kinsta®
kinsta.com › home › resource center › blog › javascript tutorials › unleashing the power of javascript spread operator
Unleashing the Power of JavaScript Spread Operator - Kinsta®
October 1, 2025 - The spread operator in JavaScript is a syntax introduced in ECMAScript 6 (ES6) that allows you to spread the elements of an iterable (such as arrays, strings, or objects), into another iterable or function call.
🌐
W3Schools
w3schools.com › jsref › jsref_oper_spread.asp
JavaScript Spread Operator
The ... operator can be used to join arrays: const arr1 = [1, 2, 3]; const arr2 = [4, 5, 6]; const arr3 = [...arr1, ...arr2]; Try it Yourself » · More Examples Below ! The Spread Operator (...) spreads iterables into individual elements.
🌐
Stack Abuse
stackabuse.com › spread-operator-in-javascript
Spread Operator in JavaScript
August 24, 2023 - In this tutorial, we'll demystify those three dots ... of JavaScript that does amazing things with iterables. There are different usages of the spread operator and each usage target to solve a different problem statement. We can use the spread operator on iterables like a String or an array and it'll put the contents of the iterable into individual elements.
🌐
Medium
eleftheriabatsou.medium.com › javascript-spread-operator-explained-with-examples-a38caf568ffd
JavaScript Spread Operator Explained (with Examples) | by Eleftheria Batsou | Medium
September 30, 2024 - By the end, you’ll have a solid understanding of how the spread operator can be used to streamline your JavaScript code. The spread operator (...) is a convenient way to expand elements of an array or object into individual elements. It's often used to make copies of arrays or objects, combine data, or pass multiple arguments to functions. One of the most common uses of the spread operator is with arrays. Let’s look at a few examples:
🌐
CodeShack
codeshack.io › home › references › javascript › ...
JavaScript Spread (...) Operator: Syntax & Examples
June 23, 2026 - The spread operator, three dots, takes a collection and spreads it out into individual pieces. In an array literal, [...arr] drops in every element of arr; [...a, ...b] is a clean way to merge two arrays (the modern stand-in for concat()).
🌐
Educative
educative.io › answers › what-is-the-spread-operator-in-javascript
What is the spread operator in JavaScript?
The spread operator is a new addition to the set of operators in JavaScript ES6. It takes in an iterable (e.g an array) and expands it into individual elements.
Top answer
1 of 3
13

UPDATE

Spread syntax allows you to spread an array into an object (arrays are technically objects, as is mostly everything in js). When you spread an array into an object, it will add a key: value pair to the object for each array item, where the key is the index and the value is the value stored at that index in the array. For example:

const arr = [1,2,3,4,5]
const obj = { ...arr } // { 0: 1, 1: 2, 2: 3, 3: 4, 4: 5 }

const arr2 = [{ name: 'x' }, { name: 'y' }]
const obj2 = { ...arr2 } // { 0: { name: 'x' }, 1: { name: 'y' } }

You can also spread strings into arrays and objects as well. For arrays, it will behave similarly as String.prototype.split:

const txt = 'abcdefg'
const arr = [...txt] // ['a','b','c','d','e','f', 'g']

For objects, it will split the string by character and assign keys by index:

const obj = { ...txt } // { 0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g' }

So you may be getting data that sort of works when you spread an array into an object. However, if the example you gave is what you're actually using, you're going to run into problems. See below.

=============

In the case of reducers in redux, when you use the spread syntax with an array it spreads each item from your array into a new array. It's basically the same as using concat:

const arr = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr, ...arr2] // [1,2,3,4,5,6]
// same as arr.concat(arr2)

With an object, the spread syntax spreads key: value pairs from one object into another:

const obj = { a: 1, b: 2, c: 3 }
const newObj = { ...obj, x: 4, y: 5, z: 6 }
// { a: 1, b: 2, c: 3, x: 4, y: 5, z: 6 }

These are two ways to help keep your data immutable in your reducers. The spread syntax copies array items or object keys/values rather than referencing them. If you do any changes in nested objects or objects in arrays, you'll have to take that into account to make sure you get new copies instead of mutated data.

If you have arrays as object keys then you can spread the entire object into a new one and then override individual keys as needed, including keys that are arrays that need updating with spread syntax. For example, an update to your example code:

const initialState = {
  images: [],
  videos: [],
  selectedVideo: ''
}

// you need all of your initialState here, not just one of the keys
export default function ( state = initialState, action ) {
  switch (action.type) {
    case types.SELECTED_VIDEO:
      // spread all the existing data into your new state, replacing only the selectedVideo key
      return {
        ...state,
        selectedVideo: action.video
      }
    case types.SHUTTER_VIDEO_SUCCESS:
      // spread current state into new state, replacing videos with the current state videos and the action videos
      return {
        ...state,
        videos: [...state.videos, ...action.videos]
      }
    default:
      return state;
  }
}

This shows updating a state object and specific keys of that object that are arrays.

In the example you give, you're changing the structure of your state on the fly. It starts as an array, then sometimes returns an array (when SHUTTER_VIDEO_SUCCESS) and sometimes returns an object (when SELECTED_VIDEO). If you want to have a single reducer function, you would not isolate your initialState to just the videos array. You would need to manage all of your state tree manually as shown above. But your reducer should probably not switch the type of data it's sending back depending on an action. That would be an unpredictable mess.

If you want to break each key into a separate reducer, you would have 3 (images, videos and selectedVideo) and use combineReducers to create your state object.

import { combineReducers } from 'redux'
// import your separate reducer functions

export default combineReucers({
  images,
  videos,
  selectedVideos
})

In that case each reducer will be run whenever you dispatch an action to generate the complete state object. But each reducer will only deal with its specific key, not the whole state object. So you would only need array update logic for keys that are arrays, etc.

2 of 3
0

According to the tutorial:

create-react-app comes preinstalled with babel-plugin-transform-object-rest-spread that lets you use the spread (…) operator to copy enumerable properties from one object to another in a succinct way. For context, { …state, videos: action.videos } evaluates to Object.assign({}, state, action.videos).

So, that's not a feature of ES6. It uses a plugin to let you use that feature.

Link: https://babeljs.io/docs/plugins/transform-object-rest-spread/

🌐
Simplyjavascript
simplyjavascript.com › tutorials › spread-operator
JavaScript Spread Operator
The spread operator (...) expands an iterable into individual elements. Use it to copy an array without modifying the original.