SlideShare a Scribd company logo
Underscore.js
-- a utility-belt library for JavaScript
                                By zfcao@corp.netease.com
                                              2012-09-07
underscore ?

不扩展任何 JavaScript 的原生对象


委托浏览器原生的方法


向上兼容 es5
Underscore
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)
Underscore
思考:把 {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.html

http://underscorejs.org/

http://www.css88.com/doc/underscore
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
THE END
THANK YOU

More Related Content

PPTX
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
PPTX
Study4.TW .NET Conf 2018 - Fp in c#
PDF
Node way
PDF
05 MapKit and Text Input
PDF
02 Objective-C
PDF
使用 Eloquent ORM
PDF
不断归零的前端人生 - 2016 中国软件开发者大会
PDF
開發流程與工具介紹
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
Study4.TW .NET Conf 2018 - Fp in c#
Node way
05 MapKit and Text Input
02 Objective-C
使用 Eloquent ORM
不断归零的前端人生 - 2016 中国软件开发者大会
開發流程與工具介紹

What's hot (19)

PDF
KISSY for starter
PPT
Web设计 4 锋利的j_query(进入企业级应用阶段)
PDF
14 Saving Loading and Application States
PDF
Migrations 與 Schema 操作
PDF
CRUD 綜合運用
PPT
JQuery 学习
PDF
Migrations 與 Schema操作
PDF
The Evolution of Async Programming (GZ TechParty C#)
PPT
编辑器设计U editor
PDF
Model & Seeding整合
PDF
Schema & Migration操作
PDF
Eloquent ORM
PPTX
Yui3.3.0 node
PDF
redux-observable with react-apollo
PPTX
jQuery源码学习
PDF
Template mb-kao
PDF
编辑器设计Kissy editor
PPT
Node.js在淘宝的应用实践
PDF
Java script closures
KISSY for starter
Web设计 4 锋利的j_query(进入企业级应用阶段)
14 Saving Loading and Application States
Migrations 與 Schema 操作
CRUD 綜合運用
JQuery 学习
Migrations 與 Schema操作
The Evolution of Async Programming (GZ TechParty C#)
编辑器设计U editor
Model & Seeding整合
Schema & Migration操作
Eloquent ORM
Yui3.3.0 node
redux-observable with react-apollo
jQuery源码学习
Template mb-kao
编辑器设计Kissy editor
Node.js在淘宝的应用实践
Java script closures
Ad

Viewers also liked (7)

KEY
Underscore.js
PPS
Underscore
PDF
Underscore.js
PPTX
Introduction to Underscore.js
PDF
Introduction to Underscore.js
PDF
The Top Skills That Can Get You Hired in 2017
Underscore.js
Underscore
Underscore.js
Introduction to Underscore.js
Introduction to Underscore.js
The Top Skills That Can Get You Hired in 2017
Ad

Similar to Underscore (20)

PPTX
Ecma script edition5-小试
PPT
Javascript之昨是今非
PPTX
前端测试
PPTX
前端测试
KEY
D2_Node在淘宝的应用实践
PPT
Javascript Training
PDF
Banquet 15
PDF
Maintainable Javascript
PDF
JavaScript 教程
PDF
JavaScript Engine
PDF
Ecmascript
PPTX
Html5培训内容
PDF
SeaJS - 前端模块化开发探索与网站性能优化实践
PPTX
追风堂 Javascript
PPTX
ES5 introduction
PDF
Js is js(程劭非) (1)
PDF
JavaScript 快速複習 2017Q1
PDF
前端爆肝之旅+React上山前的小專案心得分享
PPT
Ajax Lucence
PDF
Javascript进阶编程
Ecma script edition5-小试
Javascript之昨是今非
前端测试
前端测试
D2_Node在淘宝的应用实践
Javascript Training
Banquet 15
Maintainable Javascript
JavaScript 教程
JavaScript Engine
Ecmascript
Html5培训内容
SeaJS - 前端模块化开发探索与网站性能优化实践
追风堂 Javascript
ES5 introduction
Js is js(程劭非) (1)
JavaScript 快速複習 2017Q1
前端爆肝之旅+React上山前的小專案心得分享
Ajax Lucence
Javascript进阶编程

Underscore