lodash常用函数解释
来源:互联网 发布:淘宝申请退货在哪里 编辑:程序博客网 时间:2024/06/11 05:19
_.assign(object, [sources], [customizer], [thisArg])
作用:分配源对象可列举的属性给目标对象,后来分配的源会覆盖先前的源
object :目标对象
sources :可选,源对象
customizer :可选,自定义函数的值
thisArg :绑定的编辑器
返回值: 对象
例子:
_.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });// => { 'user': 'fred', 'age': 40 }
_.get(object, path, [defaultValue])
作用:获取对象给定路径的属性值,如果获取不到值,将返回默认值
object : 要查询的对象path : 要获取的属性的路径
defaultValue : 默认值
例子:
var object = { 'a': [{ 'b': { 'c': 3 } }] };_.get(object, 'a[0].b.c');// => 3_.get(object, ['a', '0', 'b', 'c']);// => 3_.get(object, 'a.b.c', 'default');// => 'default'
_.includes(collection, target, [fromIndex=0])
作用:检查collection中是否含有targetcollection : 数组,对象或者字符串
target : 要搜索的值
fromIindex : 开始搜索的下标,如果下标为负,那其表示距离end节点的距离
例子:
_.includes([1, 2, 3], 1);// => true_.includes([1, 2, 3], 1, 2);// => false_.includes({ 'user': 'fred', 'age': 40 }, 'fred');// => true_.includes('pebbles', 'eb');// => true
_.forOwn(object, [iteratee=_.identity], [thisArg])
作用:遍历对象自身可枚举的属性
object : 要遍历的对象
iteratee=_.identity : 被每一个迭代调用的函数,可选
thisArg : iteratee绑定的参数(暂不知道用处)
例子:
function Foo() { this.a = 1; this.b = 2;}Foo.prototype.c = 3;_.forOwn(new Foo, function(value, key) { console.log(key);});// => logs 'a' and 'b' (iteration order is not guaranteed)
0 0
- lodash常用函数解释
- Lodash中十个常用的工具函数
- Lodash中十个常用的工具函数
- lodash常用API
- lodash difference 函数demo
- lodash
- lodash
- lodash
- Lodash
- lodash
- CamShift 常用函数解释。
- Apache常用函数解释
- opengl常用函数解释
- oracle 常用函数例子解释
- MATLAB 常用函数的解释
- lodash中pick和omit函数介绍
- IronPython:交互式解释器与常用函数
- linux内核常用数据结构和函数解释
- php7开启强类型模式
- 关键字、结构体总结以及typedef,枚举与#define区别
- 函数和函数库
- Android设置透明、半透明等效果
- Dialog源码分析
- lodash常用函数解释
- 寻找Coder(toupper 的用法)--------去哪儿2015研发工程师笔试题
- Roman to Integer
- 分享一篇利用poi 写的将excel转化为map的方法
- 首个重复字符(map的用法)----去哪儿2015研发工程师笔试题
- 优酷视频控制
- zcmu1736
- POJ 1915 BFS 同HDU1372
- 使用Windows 自带的 sc 工具操作驱动程序