assignIn extend
最后更新于:2022-04-02 00:04:31
## assignIn extend
+ [link](./assignIn "Link to this entry.")
+ [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L10736 "View in source.")
+ [npm](https://www.npmjs.com/package/lodash.assignin "See the npm package.")
```
_.assignIn(object, [sources])
```
这个方法类似 `_.assign`。 除了它会遍历并继承来源对象的属性。
**注意:** 这方法会改变源对象
### 参数
1. object (Object)
目标对象
2. [sources] (...Object)
来源对象
### 返回值 (Object)
返回对象
### 示例
```
function Foo() {
this.b = 2;
}
function Bar() {
this.d = 4;
}
Foo.prototype.c = 3;
Bar.prototype.e = 5;
_.assignIn({ 'a': 1 }, new Foo, new Bar);
// => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
```
';