# \_.mergeWith

**语法：**

```javascript
_.mergeWith(object, sources, customizer)
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L13471)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.mergewith)

**描述：**

该方法类似[`_.merge`](https://lodash.com/docs/4.17.10#merge)，除了它接受一个`customizer`，调用以产生目标对象和来源对象属性的合并值。如果`customizer`返回`undefined`，将会由合并处理方法代替。`customizer`调用与7个参数：*(objValue, srcValue, key, object, source, stack)*。

> **Note:**&#x8FD9;方法会改变对象`object`.

**开始版本：**&#x34;.0.0

**参数：**

* `object (Object)`: 目标对象。
* `[sources] (...Object)`: 来源对象。
* `customizer (Function)`: 这个函数定制合并值。

**返回值：**

* `(Object)`: 返回 object。

**例子：**

```javascript
function customizer(objValue, srcValue) {
  if (_.isArray(objValue)) {
    return objValue.concat(srcValue);
  }
}

var object = { 'a': [1], 'b': [2] };
var other = { 'a': [3], 'b': [4] };

_.mergeWith(object, other, customizer);
// => { 'a': [1, 3], 'b': [2, 4] }
```


---

# 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://lodash.shujuwajue.com/object/mergewith.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.
