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

Underscore

on

  • 1,058 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,058
Views on SlideShare
1,057
Embed Views
1

Actions

Likes
2
Downloads
0
Comments
0

1 Embed 1

http://localhost 1

Accessibility

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 Underscore Presentation Transcript

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