diff --git a/index.html b/index.html index 3ac282394..97cd8e031 100644 --- a/index.html +++ b/index.html @@ -748,10 +748,11 @@ _.functions(_);
- extend_.extend(destination, source)
+ extend_.extend(destination, *sources)
- Copy all of the properties in the source object over to the
- destination object.
+ Copy all of the properties in the source objects over to the
+ destination object. It's in-order, to the last source will override
+ properties of the same name in previous arguments.
_.extend({name : 'moe'}, {age : 50});
diff --git a/underscore.js b/underscore.js
index 0a31cea03..1d835f357 100644
--- a/underscore.js
+++ b/underscore.js
@@ -432,11 +432,10 @@
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) {
- var prop;
- each(_.rest(arguments), function (source) {
- for (prop in source) obj[prop] = source[prop];
+ each(_.rest(arguments), function(source) {
+ for (var prop in source) obj[prop] = source[prop];
});
return obj;
};