hel*_*hod 92 javascript jquery underscore.js
我刚开始学习JavaScript,偶然发现了Underscore.js和jQuery.Underscore看起来很酷,但我想知道jQuery是否还没有提供类似于Underscore的功能.那么,同时使用它们是否值得?
rkw*_*rkw 68
Ume*_*til 39
Underscore提供了总共60个用于处理数据/代码的函数.同意许多功能存在于其他库中,如jQuery,Prototype或script.aculo.us.例如,jQuery中存在像each,map,find,filter或toArray这样的函数.这些也在Underscore中.这是为了使库独立于jQuery.
什么时候使用下划线?:
目前,它与Backbone.js广泛使用,以使用MVC架构来创建单页Javascript Web应用程序.underscore.js最重要的能力是模板化的能力(jQuery无法做到).该库还有许多其他有用的函数,它们独立于其他Javascript库.
在下面找到Underscore提供的功能列表:
集合: each,map,reduce,reduceRight,find,filter,reject,all,any,include,invoke,pluck,max,min,sortBy,groupBy,sortedIndex,shuffle,toArray,size
数组: first,initial,last,rest,compact,flatten,without,union,intersection,difference,uniq,zip,indexOf,lastIndexOf,range
功能: bind,bindAll,memoize,delay,defer,throttle,debounce,once,after,wrap,compose
对象: 键,值,函数,扩展,默认值,克隆,tap,isEqual,isEmpty,isElement,isArray,isArguments,isFunction,isString,isNumber,isBoolean,isDate,isRegExp,isNaN,isNull,isUndefined
Utitity: noConflict,identity,times,mixin,uniqueId,escape,template
如果您担心重叠,并且不需要像JQuery AJAX这样的东西,那么您可以考虑仅使用名为Sizzle的JQuery选择器引擎.
请注意,这不适用于所有项目,通过使用Sizzle和Underscore,您将失去一些JQuery功能(如AJAX),您需要考虑您的特定应用程序真正需要的内容.
| 归档时间: |
|
| 查看次数: |
31778 次 |
| 最近记录: |