使用omit/pick代替delect
~~~
var object = { 'a': 1, 'b': '2', 'c': 3 };
_.omit(object, ['a', 'c']);
// => { 'b': '2' }
~~~
使用some代替(map+flag)
~~~
_.some([null, 0, 'yes', false], Boolean);
// => true
var users = [
{ 'user': 'barney', 'active': true },
{ 'user': 'fred', 'active': false }
];
// The `_.matches` iteratee shorthand.
_.some(users, { 'user': 'barney', 'active': false });
// => false
// The `_.matchesProperty` iteratee shorthand.
_.some(users, ['active', false]);
// => true
// The `_.property` iteratee shorthand.
_.some(users, 'active');
// => true
~~~
使用zipObject改造对应的值
~~~
_.zipObject(['a', 'b'], [1, 2]);
// => { 'a': 1, 'b': 2 }
~~~
使用uniqWith实现对象数组去重
~~~
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
_.uniqWith(objects, _.isEqual);
// => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
~~~
使用compact代替filter(i=>i)
~~~
_.compact([0, 1, false, 2, '', 3]);
// => [1, 2, 3]
~~~
~~~
debounce,
isEmpty,
isEqual,
omit,
zipObject,
isObject,
isArray,
pick,
~~~