mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
merging ratbeard's patch for allowing multiple arguments to be passed to extend, with docs
This commit is contained in:
@@ -748,10 +748,11 @@ _.functions(_);
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p id="extend">
|
<p id="extend">
|
||||||
<b class="header">extend</b><code>_.extend(destination, source)</code>
|
<b class="header">extend</b><code>_.extend(destination, *sources)</code>
|
||||||
<br />
|
<br />
|
||||||
Copy all of the properties in the <b>source</b> object over to the
|
Copy all of the properties in the <b>source</b> objects over to the
|
||||||
<b>destination</b> object.
|
<b>destination</b> object. It's in-order, to the last source will override
|
||||||
|
properties of the same name in previous arguments.
|
||||||
</p>
|
</p>
|
||||||
<pre>
|
<pre>
|
||||||
_.extend({name : 'moe'}, {age : 50});
|
_.extend({name : 'moe'}, {age : 50});
|
||||||
|
|||||||
@@ -432,11 +432,10 @@
|
|||||||
return _.filter(_.keys(obj), function(key){ return _.isFunction(obj[key]); }).sort();
|
return _.filter(_.keys(obj), function(key){ return _.isFunction(obj[key]); }).sort();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend a given object with all the properties in given object(s)
|
// Extend a given object with all the properties in passed-in object(s).
|
||||||
_.extend = function(obj) {
|
_.extend = function(obj) {
|
||||||
var prop;
|
each(_.rest(arguments), function(source) {
|
||||||
each(_.rest(arguments), function (source) {
|
for (var prop in source) obj[prop] = source[prop];
|
||||||
for (prop in source) obj[prop] = source[prop];
|
|
||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user