Syntax

JavaScript Spread Syntax Syntax

In JavaScript, spread syntax: copies or merges arrays and objects — const merged = { ...a, ...b };

Quick Answer

Syntax
const merged = { ...a, ...b };
JavaScriptSyntax

Spread Syntax

Code example
const merged = { ...a, ...b };

Copies or merges arrays and objects.

Learn More

How to spread syntax in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Spread Syntax Syntax

Use const merged = { ...a, ...b };.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for spread syntax?

Use this pattern: const merged = { ...a, ...b };

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify