let original = {name: 'Joel', favoriteFood: 'oranges', age: 26};
let happyBirthday = {...original, age: 27};
happyBirthday will be an object that is identical to original but with the age overwritten.
So that would result in an object like this:
{name: 'Joel', favoriteFood: 'oranges', age: 27} // Notice the age
Answer from Pedro Filipe on Stack OverflowMDN 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 ... array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value pairs to the object being created....
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-spread-operator
JavaScript Spread Operator - GeeksforGeeks
The spread operator (...) with objects is used to create copies of existing objects with new or updated values or to make a copy of an object with more properties. Let's take an example of how to use the spread operator on an object, ... Here ...
Published January 16, 2026
javascript - Quick question about ES6 spread operator on objects - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I just have a brief question about using spread operators on objects, when we are trying to return a copy of the object with a field changed. More on stackoverflow.com
Adding arbitrary attributes to object using spread operator
It’s not really a bug. If they performed excess property checks with spreading, the resulting errors would be very awkward to work around. Generally, typescript doesn’t care about excess properties. This is why Object.keys emits strings and not keyof T. More on reddit.com
C# 12 spread operator in practice
I'm convinced this is a feature I'm going to see in Reddit threads by confused newbies 99.9999% more than in discussions of solutions to a problem. More on reddit.com
Items is not iterable in spread operator?
Show the parameter you are passing in as the items More on reddit.com
How to Use the Spread Operator in JavaScript
11:09
ES6 Spread Operator: Simplify Array and Object Manipulation in ...
04:55
JavaScript SPREAD OPERATOR in 4 minutes! 📖 - YouTube
- YouTube
09:20
The JavaScript Spread Operator - One Thing You DIDN'T KNOW! - YouTube
W3Schools
w3schools.com › react › react_es6_spread.asp
React ES6 Spread Operator
React Compiler React Quiz React Exercises React Syllabus React Study Plan React Server React Interview Prep React Bootcamp ... The JavaScript spread operator (...) copies all or part of an existing array or object into another array or object.
DigitalOcean
digitalocean.com › community › tutorials › js-spread-operator
What's the Spread Operator Used For in JavaScript? | DigitalOcean
July 11, 2022 - The spread operator is a feature of JavaScript introduced with ES6 that gives you access to the insides of an iterable object. An “iterable object” is anything you can iterate over item by item, such as arrays, objects literals, and strings. These kinds of JavaScript types can be traversed ...
Top answer 1 of 2
7
let original = {name: 'Joel', favoriteFood: 'oranges', age: 26};
let happyBirthday = {...original, age: 27};
happyBirthday will be an object that is identical to original but with the age overwritten.
So that would result in an object like this:
{name: 'Joel', favoriteFood: 'oranges', age: 27} // Notice the age
2 of 2
5
Objects cannot have duplicate keys. If you assign a key to an object when that object already has said key, or write an object initializer with duplicate keys, the prior value at that key will be overwritten:
const obj = {
foo: 'foo',
bar: 'bar',
};
obj.foo = 'new';
console.log(obj);
const obj = {
foo: 'foo',
bar: 'bar',
foo: 'new',
};
console.log(obj);
When using object spread, the same sort of thing is going on. If you add a key-value pair when a prior key already exists in the object initializer (by spread or otherwise), the prior value will be overwritten.
let happyBirthday = {...original, age: 27};
is very similar to
// Create a new object with all properties of `original`:
let happyBirthday = Object.assign({}, original);
// Assign to the `age` property of the new object:
happyBirthday.age = 27;
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript object spread
JavaScript Object Spread Operator (...) - JavaScript Tutorial
November 4, 2024 - The spread operator (...) can be used to merge two or more arrays into one as shown in the following example: let rgb = [ 'red', 'green', 'blue' ]; let cmyk = ['cyan', 'magenta', 'yellow', 'black']; let merge = [...rgb, ...cmyk]; console.lo...
Stack Abuse
stackabuse.com › spread-operator-in-javascript
Spread Operator in JavaScript
August 24, 2023 - As we can see, the arr2 wasn't passed a reference like before, but rather it was populated with the values of arr1 as a whole new object. So even when arr1 changes, arr2 remains the same. We can also use the spread operator to create a copy of an array and add new elements into it at the same time:
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.
W3Schools
w3schools.in › javascript › spread-operator
JavaScript Spread Operator - W3Schools
The spread operator, represented by three dots (...), expands elements of an iterable (like arrays) or object properties. It was introduced in ES6 and has become a staple in JavaScript programming for its simplicity and efficiency.
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.
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › javascript spread operator
The Practical Usages of JavaScript Spread Operator
May 8, 2024 - When we applied 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....