Underscore和lodash 介绍 ,js 工具库

https://blog.csdn.net/weixin_41849462/article/details/88558354

Lodash是一个具有一致接口、模块化、高性能的JavaScript工具库。一开始Lodash只是Underscore.js的一个fork,之后再原有的成功基础上取得了更大的成果,lodash的性能远远的超过了Underscore。因此,很多模块放弃了Underscore转入Lodash的怀抱。目前,lodash是npm仓库中依赖最多的库。使用lodash的全部函数需要使用全局的_就像是使用jQuery的函数前加上全局的$一样。lodash的使用极大的减少了你的代码量以及编写代码时间。[附上lodash的API文档](http://lodashjs.com/docs/) ]http://lodashjs.com/docs/
 

其他参考

由 Underscore 与 Lodash 的差异引发的思考

你并不需要Underscore/Lodash

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Collection Functions (Arrays or Objects) _.each(list, iterator, [context]) Alias: forEach Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is bound to the _.map(list, iterator, [context]) Alias: collect Produces a new array of values by mapping each value in list through a transformation function ( _.reduce(list, iterator, memo, [context]) Aliases: inject, foldl Also known as inject and foldl, reduce boils down a list of values into a single value. _.reduceRight(list, iterator, memo, [context]) Alias: foldr The right-associative version of reduce. Delegates to the JavaScript 1.8 version of _.find(list, iterator, [context]) Alias: detect Looks through each value in the list, returning the first one that passes a truth test (iterator). The function returns as _.filter(list, iterator, [context]) Alias: select Looks through each value in the list, returning an array of all the values that pass a truth test ( _.where(list, properties) Looks through each value in the list, returning an array of all the values that contain all of the key-value pairs listed in _.findWhere(list, properties) Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. _.reject(list, iterator, [context]) Returns the values in list without the elements that the truth test (iterator) passes. The opposite of filter. _.every(list, iterator, [context]) Alias: all Returns true if all of the values in the list pass the iterator truth test. Delegates to the native method _.some(list, [iterator], [context]) Alias: any Returns true if any of the values in the list pass the iterator truth test. Short-circuits and stops traversing the list _.contains(list, value) Alias: include Returns true if the value is present in the list. Uses indexOf internally, if list is an Array. _.invoke(list, methodName, [*arguments]) Calls the method named by methodName on each value in the list. Any extra arguments passed to _.pluck(list, propertyName) A convenient version of what is perhaps the most common use-case for map: extracting a list of property values. _.max(list, [iterator], [context]) Returns the maximum value in list. If iterator is passed, it will be used on each value to generate the criterion by which the _.min(list, [iterator], [context]) Returns the minimum value in list. If iterator is passed, it will be used on each value to generate the criterion by which the _.sortBy(list, iterator, [context]) Returns a sorted copy of list, ranked in ascending order by the results of running each value through iterator _.groupBy(list, iterator, [context]) Splits a collection into sets, grouped by the result of running each value through iterator. If iterator is a string instead of _.countBy(list, iterator, [context]) Sorts a list into groups and returns a count for the number of objects in each group. Similar to groupBy _.shuffle(list) Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. _.toArray(list) Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting the arguments object. _.size(list) Return the number of values in the list.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值