您的位置:首页 > 移动开发 > Objective-C

underscore.js _.extend[Object]

2012-04-16 21:42 405 查看
Copy all of the properties in the source objects over to the destination object, and return the destination object. It's in-order, so the last source will override properties of the same name in previous arguments.

将源对象属性复制到目标对象,并返回目标对象。它是有序的,所以最后的来源将覆盖以前参数名称相同的属性。

_.extend({name : 'moe'}, {age : 50});
=> {name : 'moe', age : 50}


源码:

_.extend = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
obj[prop] = source[prop];
}
});
return obj;
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: