• Save
Underscore
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Underscore

on

  • 1,160 views

 a utility-belt library for JavaScript By zfcao@corp.netease.com at

 a utility-belt library for JavaScript By zfcao@corp.netease.com at
2012-09-07

Statistics

Views

Total Views
1,160
Views on SlideShare
1,159
Embed Views
1

Actions

Likes
2
Downloads
0
Comments
0

1 Embed 1

http://localhost 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Underscore Presentation Transcript

  • 1. Underscore.js-- a utility-belt library for JavaScript By zfcao@corp.netease.com 2012-09-07
  • 2. underscore ?不扩展任何 JavaScript 的原生对象委托浏览器原生的方法向上兼容 es5
  • 3. 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
  • 4. Jquery -- dom(browser)Underscore help html5 in client  and node in server!!
  • 5. 所以咧…… Tips: 并不完全能取代 jquery.util ,旨在补充 jquery 或 raw javascript _.groupBy _.reduce _.reject _.include _.sortBy _.key(obj)_.bind(func ,object) _.memorize(func,[hashFunc]) _.throttle(func,wait)
  • 6. 思考:把 {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("&");
  • 7. jquery backbone 用来实现前端 MVC 架构组织提供 dom 操作, ajax 支 •Model持 •View •Collection •router underscore 对 ecmascript 补充,提供 常用方法的支持 eg : http://arturadib.com/hello-backbonejs/docs/5.html
  • 8. 用到我们项目中去 :
  • 9. api:http://documentcloud.github.com/underscore/docs/underscore.htmlhttp://underscorejs.org/http://www.css88.com/doc/underscore
  • 10. MORE:Underscore 竟然有 php, lua, perl 的移植了 ?http://brianhaveri.github.com/Underscore.php/http://vti.github.com/underscore-perl/http://mirven.github.com/underscore.lua/http://lodash.com/ 是对 underscore的改进,号称 8 倍速度于 underscore
  • 11. THE ENDTHANK YOU