Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2015.
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 pairs to the object being created.
Spread syntax looks exactly like rest syntax. In a way, spread syntax is the opposite of rest syntax. Spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element. See rest parameters and rest property.
Spread syntax can be used when all elements from an object or array need to be included in a new array or object, or should be applied one-by-one in a function call's arguments list. There are three distinct places that accept the spread syntax:
Although the syntax looks the same, they come with slightly different semantics.
Only iterable values, like Array and String, can be spread in array literals and argument lists. Many objects are not iterable, including all plain objects that lack a Symbol.iterator method:
On the other hand, spreading in object literals enumerates the own properties of the value. For typical arrays, all indices are enumerable own properties, so arrays can be spread into objects.
All primitives can be spread in objects. Only strings have enumerable own properties, and spreading anything else doesn't create properties on the new object.
When using spread syntax for function calls, be aware of the possibility of exceeding the JavaScript engine's argument length limit. See Function.prototype.apply() for more details.
It is common to use Function.prototype.apply() in cases where you want to use the elements of an array as arguments to a function.
With spread syntax the above can be written as:
Any argument in the argument list can use spread syntax, and the spread syntax can be used multiple times.
When calling a constructor with new, it's not possible to directly use an array and apply(), because apply() calls the target function instead of constructing it, which means, among other things, that new.target will be undefined. However, an array can be easily used with new thanks to spread syntax:
Without spread syntax, the array literal syntax is no longer sufficient to create a new array using an existing array as one part of it. Instead, imperative code must be used using a combination of methods, including push(), splice(), concat(), etc. With spread syntax, this becomes much more succinct:
Just like spread for argument lists, ... can be used anywhere in the array literal, and may be used more than once.
You can use spread syntax to make a shallow copy of an array. Each array element retains its identity without getting copied.
Spread syntax effectively goes one level deep while copying an array. Therefore, it may be unsuitable for copying multidimensional arrays. The same is true with Object.assign() — no native operation in JavaScript does a deep clone. The web API method structuredClone() allows deep copying values of certain supported types. See shallow copy for more details.
Array.prototype.concat() is often used to concatenate an array to the end of an existing array. Without spread syntax, this is done as:
With spread syntax this becomes:
Array.prototype.unshift() is often used to insert an array of values at the start of an existing array. Without spread syntax, this is done as:
With spread syntax, this becomes:
Note: Unlike unshift(), this creates a new arr1, instead of modifying the original arr1 array in-place.
You can make an element present or absent in an array literal, depending on a condition, using a conditional operator.
When the condition is false, we spread an empty array, so that nothing gets added to the final array. Note that this is different from the following:
In this case, an extra undefined element is added when isSummer is false, and this element will be visited by methods such as Array.prototype.map().
You can use spread syntax to merge multiple objects into one new object.
A single spread creates a shallow copy of the original object (but without non-enumerable properties and without copying the prototype), similar to copying an array.
When one object is spread into another object, or when multiple objects are spread into one object, and properties with identical names are encountered, the property takes the last value assigned while remaining in the position it was originally set.
You can make an element present or absent in an object literal, depending on a condition, using a conditional operator.
The case where the condition is false is an empty object, so that nothing gets spread into the final object. Note that this is different from the following:
In this case, the watermelon property is always present and will be visited by methods such as Object.keys().
Because primitives can be spread into objects as well, and from the observation that all falsy values do not have enumerable properties, you can simply use a logical AND operator:
In this case, if isSummer is any falsy value, no property will be created on the fruits object.
Note that Object.assign() can be used to mutate an object, whereas spread syntax can't.
In addition, Object.assign() triggers setters on the target object, whereas spread syntax does not.
You cannot naively re-implement the Object.assign() function through a single spreading:
In the above example, the spread syntax does not work as one might expect: it spreads an array of arguments into the object literal, due to the rest parameter. Here is an implementation of merge using the spread syntax, whose behavior is similar to Object.assign(), except that it doesn't trigger setters, nor mutates any object:
| ECMAScript® 2027 Language Specification # prod-SpreadElement |
| ECMAScript® 2027 Language Specification # prod-ArgumentList |
| ECMAScript® 2027 Language Specification # prod-PropertyDefinition |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 20, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.