1.返回指定在obj中返回指定key得对象,
keys可以是字符串,各个key值以空格分隔
function(obj, keys){
obj = obj || {};
if ('string' == typeof keys) keys = keys.split(/ +/);
return keys.reduce(function(ret, key){
if (null == obj[key]) return ret;
ret[key] = obj[key];
return ret;
}, {});
};
网友评论