Lodash篇
1.深层查找属性值
var ownerArr = [{
"owner": "Colin",
"pets": [{"name": "dog1"}, {"name": "dog2"}]
}, {
"owner": "John",
"pets": [{"name": "dog3"}, {"name": "dog4"}]
}];
var lodashMap = _.map(ownerArr, 'pets[0].name');
console.log('------- lodashMap -------');
console.log(lodashMap); -> ["dog1","dog3"]
2.深克隆对象
var objA = {
"name": "戈德斯文"
};
var objB = _.cloneDeep(objA);
console.log(objA === objB); -> false
3.在指定范围内获取一个随机值
getRandomNumber(15, 20);
你也可以指定返回的结果为浮点数_.random(15,20,true);