I feel like that article should talk about using the spread operator to deal with immutable array / object operations, e.g., for Redux in a reducer: return { ...state, field: { ...state.field, subField3: newValue } }; Answer from cordev on reddit.com
🌐
freeCodeCamp
freecodecamp.org › news › three-dots-operator-in-javascript
... in JavaScript – the Three Dots Operator in JS
November 7, 2024 - The three dots operator in JavaScript is one of the significant updates that was shipped with ES6. This operator (...) helps you achieve many things that previously required many lines of code, unfamiliar syntax, and more. In this short article, you ...
🌐
Medium
medium.com › techtofreedom › 3-uses-of-the-three-dots-in-javascript-8d6b83f179ce
3 Uses of the Three Dots in JavaScript | by Yang Zhou | TechToFreedom | Medium
June 20, 2021 - 3 Uses of the Three Dots in JavaScript Make your JavaScript code much more elegant If you read any modern JavaScript programs, you probably will meet one thing many times — the ellipsis. It is just …
🌐
Medium
oprearocks.medium.com › what-do-the-three-dots-mean-in-javascript-bc5749439c9a
What do the three dots (…) mean in JavaScript? | by Adrian Oprea | Medium
August 27, 2018 - const numbers1 = [1, 2, 3, 4, 5];const numbers2 = [ ...numbers1, 1, 2, 6,7,8]; // this will be [1, 2, 3, 4, 5, 1, 2, 6, 7, 8] Think of it as a replacement for Array.prototype.concat. When used within the signature of a function, where the function’s arguments should be, either replacing the arguments completely or alongside the function’s arguments, the three dots are also called the rest operator.
🌐
CoreUI
coreui.io › blog › what-are-the-three-dots-in-javascript-do
What are the three dots <code>...</code> in JavaScript do? · CoreUI
September 3, 2024 - Understanding the three dots operator—whether as a spread operator or a rest operator—is essential for any software developer working with JavaScript. It provides a more intuitive way to handle arrays, objects, and function parameters.
🌐
Built In
builtin.com › articles › three-dots-in-javascript
What Are the Three Dots (...) in JavaScript | Built In
The three dots (...) in JavaScript is known as the spread operator, and it’s used to make shallow copies of JavaScript objects.
🌐
Reddit
reddit.com › r/javascript › what do the three dots (...) mean in javascript?
r/javascript on Reddit: What do the three dots (...) mean in JavaScript?
August 24, 2018 - arr = [ 4, 5, 6 ]; arr[Symbol.iterator] = null; [ 1, 2, 3 ].concat(arr); //-> [ 1, 2, 3, 4, 5, 6 ] [ 1, 2, 3, ...arr ]; // Error, not iterable obj = { a: 4, b: 5, c: 6 }; obj[Symbol.iterator] = () => Object.values(obj).values(); [ 1, 2, 3 ].concat(obj); //-> [ 1, 2, 3, { a: 4, b: 5, c: 6 } ] [ 1, 2, 3, ...obj ]; //-> [ 1, 2, 3, 4, 5, 6 ] // works because iterable · When used within the signature of a function, where the function’s arguments should be, either replacing the arguments completely or alongside the function’s arguments, the three dots are also called the rest operator...
Top answer
1 of 16
1637

That's property spread notation. It was added in ES2018 (spread for arrays/iterables was earlier, ES2015), but it's been supported in React projects for a long time via transpilation (as "JSX spread attributes" even though you could do it elsewhere, too, not just attributes).

{...this.props} spreads out the "own" enumerable properties in props as discrete properties on the Modal element you're creating. For instance, if this.props contained a: 1 and b: 2, then

<Modal {...this.props} title='Modal heading' animation={false}>

would be the same as

<Modal a={this.props.a} b={this.props.b} title='Modal heading' animation={false}>

But it's dynamic, so whatever "own" properties are in props are included.

Since children is an "own" property in props, spread will include it. So if the component where this appears had child elements, they'll be passed on to Modal. Putting child elements between the opening tag and closing tags is just syntactic sugar — the good kind — for putting a children property in the opening tag. Example:

Show code snippet

class Example extends React.Component {
  render() {
    const { className, children } = this.props;
    return (
      <div className={className}>
      {children}
      </div>
    );
  }
}
ReactDOM.render(
  [
    <Example className="first">
      <span>Child in first</span>
    </Example>,
    <Example className="second" children={<span>Child in second</span>} />
  ],
  document.getElementById("root")
);
.first {
  color: green;
}
.second {
  color: blue;
}
<div id="root"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Spread notation is handy not only for that use case, but for creating a new object with most (or all) of the properties of an existing object — which comes up a lot when you're updating state, since you can't modify state directly:

this.setState(prevState => {
    return {foo: {...prevState.foo, a: "updated"}};
});

That replaces this.state.foo with a new object with all the same properties as foo except the a property, which becomes "updated":

Show code snippet

const obj = {
  foo: {
    a: 1,
    b: 2,
    c: 3
  }
};
console.log("original", obj.foo);
// Creates a NEW object and assigns it to `obj.foo`
obj.foo = {...obj.foo, a: "updated"};
console.log("updated", obj.foo);
.as-console-wrapper {
  max-height: 100% !important;
}
Run code snippetEdit code snippet Hide Results Copy to answer Expand

2 of 16
547

... are called spread attributes which, as the name represents, it allows an expression to be expanded.

var parts = ['two', 'three'];
var numbers = ['one', ...parts, 'four', 'five']; // ["one", "two", "three", "four", "five"]

And in this case (I'm going to simplify it).

// Just assume we have an object like this:
var person= {
    name: 'Alex',
    age: 35 
}

This:

<Modal {...person} title='Modal heading' animation={false} />

is equal to

<Modal name={person.name} age={person.age} title='Modal heading' animation={false} />

So in short, it's a neat short-cut, we can say.

🌐
Codingem
codingem.com › home › javascript three dots (…) operator made easy (with examples)
JavaScript Three Dots (...) Operator Made Easy (with Examples)
July 10, 2025 - In JavaScript, you can use the three dots (...) operator to spread iterable values. You can also use it to capture the rest of the values.
Find elsewhere
🌐
DEV Community
dev.to › sagar › three-dots---in-javascript-26ci
JavaScript Ellipsis: Three dots ( … ) in JavaScript - DEV Community
September 21, 2020 - When three dots (…) is at the end of function parameters, it's "rest parameters" and gathers the rest of the list of arguments into an array.
🌐
GeeksforGeeks
geeksforgeeks.org › what-are-these-triple-dots-in-javascript
What are these triple dots (…) in JavaScript ? | GeeksforGeeks
December 15, 2023 - It can be an Array or a String. It returns the argument list of the object passed after three dots. Example 1: In this example, we will concatenate two arrays using the inbuilt concat method and then perform the same task using triple dots syntax.
🌐
Fjolt
fjolt.com › article › javascript-three-dots-spread-operator
What are the three dots (...) or spread operator in Javascript?
It has a multitude of different uses, so let's take a look at how we use the spread syntax in real Javascript code. We can use the 3 dots in Javascript function calls to convert an array into a set of arguments for a function. Let's look at ...
🌐
SEOStudio
seostudio.tools › home › three dots in javascript
Three Dots in JavaScript - SEOStudio
January 29, 2026 - In JavaScript, the three dots (…) serve as two distinct operators depending on their context. These operators add to the flexibility and expressiveness of JavaScript, making the manipulation of arrays, objects, and function arguments more ...
🌐
EyeHunts
tutorial.eyehunts.com › home › three dots in javascript | example code
Three dots in JavaScript | Example code
August 1, 2023 - The three dots… are called spread attributes which, as the name represents, allow an expression to be expanded. And Rest Parameters/operator makes it possible to take all of the arguments to a function in one array.
🌐
JavaScript in Plain English
javascript.plainenglish.io › what-do-the-three-dots-spread-operator-mean-in-javascript-8f7161b4455b
What do the three dots (...) do in Javascript? | JavaScript in Plain English
November 10, 2021 - We can use the 3 dots in JavaScript function calls to convert an array into a set of arguments for a function. Let’s look at an example.
🌐
DEV Community
dev.to › anuragaffection › the-three-dots-in-javascript-b32
The three dots (...) in JavaScript - DEV Community
April 19, 2024 - The three dots (...) in JavaScript are typically used for two purposes: It allows an iterable (like an array or a string) to be expanded into individual elements. For example: const arr1 = [1, 2, 3]; const arr2 = [...arr1, 4, 5]; // arr2 is ...
🌐
Reddit
reddit.com › r/programming › 3 uses of the three dots in javascript
r/programming on Reddit: 3 Uses of the Three Dots in JavaScript
June 20, 2021 - Questions and posts about frontend development in general are welcome, as are all posts pertaining to JavaScript on the backend. ... This subreddit is devoted to Shortcuts. Shortcuts is an Apple app for automation on iOS, iPadOS, and macOS. ... User Agreement Reddit, Inc.
🌐
HackerNoon
hackernoon.com › decoding-the-three-dots-or-spread-operator-in-javascript
Decoding the Three Dots (…) Or Spread Operator in Javascript | HackerNoon
September 4, 2022 - The spread operator, spread syntax or 3 dots (...), is a type of syntax in Javascript that is used by both function calls and arrays/objects.
🌐
DEV Community
dev.to › sonicoder › the-tale-of-three-dots-in-javascript-4287
The tale of three dots in Javascript - DEV Community
February 25, 2024 - One of them was the three consecutive dots that we can write in front of any compatible container (objects, arrays, strings, sets, maps). These tiny little dots enable us to write a more elegant and concise code. I'll explain how the three dots ...