项目中常用的
_.isEmpty(value)
1
2
3
4
5
6
7
8
9
10
11
12
13
14_.isEmpty(null);
// => true
_.isEmpty(true);
// => true
_.isEmpty(1);
// => true
_.isEmpty([1, 2, 3]);
// => false
_.isEmpty({ 'a': 1 });
// => false_.isEqual(value, other) 深层的比较
1
2
3
4
5
6
7
8var object = { 'a': 1 };
var other = { 'a': 1 };
_.isEqual(object, other);
// => true
object === other;
// => falsebind 通常在react中绑定this实例
做为装饰器,使用方法@Bind()
1
2
3
4
5
6
7
8
9
10
11
12
13
14function greet(greeting, punctuation) {
return greeting + ' ' + this.user + punctuation;
}
var object = { 'user': 'fred' };
var bound = _.bind(greet, object, 'hi');
bound('!');
// => 'hi fred!'
// Bound with placeholders.
var bound = _.bind(greet, object, _, '!');
bound('hi');
// => 'hi fred!'cloneDeep 深克隆
贴一下lodash文档链接