# Copy and Merge

## Copy

Use the `wire.copy` function to make a deep copy of an object or Array.

```javascript
let data = { product: "SKU001", month: "May", sales: 300 }

const dataCopy = wire.copy(data);
```

## Merge

Use the `wire.merge` function to merge the values of one object into another.  This function take two parameters.  The first is the `target` and the second is the `source`. All  properties and their values on the source object will be copied into the target object.  If a target property already exists, it will be overwritten by the same on the source.  If not, it will be left alone.

In the example below, the `target` variable values of `product` and `sales` will be replaced with those from the `source` variable but will leave the `month` attribute alone.

```javascript
let source = { product: "SKU001", month: "May", sales: 300 }
let target = { product: "SKU431", sales: 500 }

wire.merge(target, source);

// target = { product: "SKU001", month: "May", sales: 300 }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/utilities/copy-and-merge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
