Contenu connexe
Similaire à Underscore (20)
Underscore
- 4. Underscore vs jQuery Utilities
=N aN ?
Collections : $.each vs _.each Na N ==
比较: http://jsperf.com/jquery-each-vs-for-loop/12
Arrays :
$.unique()+$.merge() vs _.union()
比较: http://jsperf.com/merge-vs-union
Objects : $.extend() vs _.extend()
比较: http://jsbin.com/atetew/5/edit
Templates:
$. template () vs _. template ()
比较: http://jsperf.com/template-vs-template
- 6. 所以咧……
Tips: 并不完全能取代 jquery.util ,旨在补充 jquery 或 raw javascript
_.groupBy
_.reduce
_.reject
_.include
_.sortBy
_.key(obj)
_.bind(func ,object) _.memorize(func,[hashFunc])
_.throttle(func,wait)
- 8. 思考:把 {a:1,b:2,c:3} 转换成“ a=1&b=2&c=3“ ?
_({a:1,b:2,c:3}).chain().map(function(v,k){return k +'=' +v}).value().join("&");
- 9. jquery backbone
用来实现前端 MVC 架构组织
提供 dom 操作, ajax 支
•Model
持
•View
•Collection
•router
underscore
对 ecmascript 补充,提供
常用方法的支持
eg : http://arturadib.com/hello-backbonejs/docs/5.html
- 12. MORE:
Underscore 竟然有 php, lua, perl 的
移植了 ?
http://brianhaveri.github.com/Undersc
ore.php/
http://vti.github.com/underscore-perl/
http://mirven.github.com/underscore.l
ua/
http://lodash.com/ 是对 underscore
的改进,号称 8 倍速度于 underscore