SlideShare a Scribd company logo
Introduction to
 Underscore.js

     David Jacobs
     @MetaThis
What Is Underscore?
• Utility library
• Provides support for functional programming
General Purpose
Client-side and Server-side
• It has nothing to do with DOM manipulation
  (unlike jQuery)
• No functionality specific to web browsers
Node.js
Most depended on module in NPM
 http://search.npmjs.org
Over 70 Functions
Collections     Arrays           Functions    Objects                 Utility
- each          - first          - bind       - keys                  - noConflict
- map           - initial        - bindAll    - values                - identity
- reduce
                - last           - memoize    - functions             - times
- reduceRight
- find          - rest           - delay      - extend                - mixin
- filter        - compact        - defer      - defaults              - uniqueId
- reject        - flatten        - throttle   - clone                 - escape
- all           - without        - debounce   - tap                   - template
- any
                - union          - once       - has
- include
- invoke        - intersection   - after      - isEqual               Chaining
- pluck         - difference     - wrap       - isEmpty               - chain
- max           - uniq           - compose    - isElement             - value
- min           - zip                         - isArray
- sortBy
                - indexOf                     - isArguments
- groupBy
- sortedIndex   - lastIndexOf                 - isFunction
- shuffle       - range                       - isString
- toArray                                     - is…(more like this)
- size
JavaScript Functions
• Functions are objects
• Functions are values
  – Can be assigned to a variable
  – Can be passed to another function as an argument
  – Can be returned by a function
Functional Programming
• Functional programming is using functions as
  a mapping from one value to another value
• Thinking and programming in a functional
  style means using higher-order functions
  – Composition
  – Chaining
Map
“Transform this array into a new array, using this transformation”
Reduce
“Accumulate a single value from an array of values”
Filter
“Give me a subset of my array that meets my conditions”
Memoize
“Cache the result”
Metaprogramming
wrap _.wrap(function, wrapper)
• Wraps the first function inside of the wrapper function, passing it as the
   first argument. This allows the wrapper to execute code before and after
   the function runs, adjust the arguments, and execute it conditionally.

tap _.tap(object, interceptor)
• Invokes interceptor with the object, and then returns object.
Functional Helpers
compose _.compose(*functions)
• Returns the composition of a list of functions, where each function
  consumes the return value of the function that follows. In math terms,
  composing the functions f(), g(), and h() produces f(g(h())).
Flow Helpers
after _.after(count, function)
• Creates a version of the function that will only be run after first being
   called count times. Useful for grouping asynchronous responses, where
   you want to be sure that all the async calls have finished, before
   proceeding.
More Info
Web Site
http://documentcloud.github.com/underscore

Github
https://github.com/documentcloud/underscore/

Annotated Source Code (useful!)
http://documentcloud.github.com/underscore/docs/underscore.html

More Related Content

KEY
Underscore.js
PPS
Underscore
PDF
Introduction to Underscore.js
PPTX
Introduction to underscore.js
PDF
Realm.io par Clement Sauvage
PDF
Artem Yavorsky "99 ways to take away your ugly polyfills"
PPTX
Introduction to es6
KEY
iOS Einführung am Beispiel von play NEXT TEE
Underscore.js
Underscore
Introduction to Underscore.js
Introduction to underscore.js
Realm.io par Clement Sauvage
Artem Yavorsky "99 ways to take away your ugly polyfills"
Introduction to es6
iOS Einführung am Beispiel von play NEXT TEE

What's hot (20)

PDF
Localforage - fast and simple storage library for JavaScript.
PDF
Elasticsearch and Symfony Integration - Debarko De
PPTX
ElasticSearch, Elastica, ElasticaBundle
PDF
Performance Optimization and JavaScript Best Practices
PDF
Java Script Best Practices
PDF
Dynamic SQL in doobie
PDF
Powerful JavaScript Tips and Best Practices
KEY
Objective C 基本介紹
PDF
React Development with the MERN Stack
PDF
2013 - Nate Abele Wield AngularJS like a Pro
KEY
Core animation
PPTX
Mongoose and MongoDB 101
PDF
Recipes to build Code Generators for Non-Xtext Models with Xtend
PDF
JavaScript in 2016
PDF
XQuery in the Cloud
PDF
Ten useful JavaScript tips & best practices
PDF
Intro to React
PDF
Building data flows with Celery and SQLAlchemy
PDF
Reactive Programming with JavaScript
PDF
An approach to responsive, realtime with Backbone.js and WebSockets
Localforage - fast and simple storage library for JavaScript.
Elasticsearch and Symfony Integration - Debarko De
ElasticSearch, Elastica, ElasticaBundle
Performance Optimization and JavaScript Best Practices
Java Script Best Practices
Dynamic SQL in doobie
Powerful JavaScript Tips and Best Practices
Objective C 基本介紹
React Development with the MERN Stack
2013 - Nate Abele Wield AngularJS like a Pro
Core animation
Mongoose and MongoDB 101
Recipes to build Code Generators for Non-Xtext Models with Xtend
JavaScript in 2016
XQuery in the Cloud
Ten useful JavaScript tips & best practices
Intro to React
Building data flows with Celery and SQLAlchemy
Reactive Programming with JavaScript
An approach to responsive, realtime with Backbone.js and WebSockets
Ad

Viewers also liked (10)

PPT
Javascript Frameworks
PDF
MVC Revivial on the Web
PDF
JS Framework Comparison - An infographic
PDF
JavaScript MV* Framework - Making the Right Choice
PPTX
Latest Javascript MVC & Front End Frameworks 2017
PPTX
Javascript Frameworks Comparison
PDF
Marionette: the Backbone framework
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
PDF
Comparing JVM Web Frameworks - February 2014
PDF
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Javascript Frameworks
MVC Revivial on the Web
JS Framework Comparison - An infographic
JavaScript MV* Framework - Making the Right Choice
Latest Javascript MVC & Front End Frameworks 2017
Javascript Frameworks Comparison
Marionette: the Backbone framework
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Comparing JVM Web Frameworks - February 2014
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Ad

Similar to Introduction to Underscore.js (20)

PPTX
Presentation on Shared Memory Parallel Programming
PPTX
What is jubatus (short)
PDF
Beyond Map/Reduce: Getting Creative With Parallel Processing
PDF
Tikal's Backbone_js introduction workshop
PDF
Play Framework and Activator
PDF
Plreuse
KEY
Enterprise Java Web Application Frameworks Sample Stack Implementation
PDF
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
PPT
Perf onjs final
KEY
Static or Dynamic Typing? Why not both?
PDF
Booting into functional programming
PPTX
Single Page Applications with AngularJS 2.0
PDF
4th European Lisp Symposium: Jobim: an Actors Library for the Clojure Program...
PPTX
Jvm memory model
PDF
WebNet Conference 2012 - Designing complex applications using html5 and knock...
PPT
My first experience with lambda expressions in java
PPTX
Functional programming for the Advanced Beginner
PPTX
Implementing a JavaScript Engine
KEY
DjangoCon 2010 Scaling Disqus
KEY
Erjang - A journey into Erlang-land
Presentation on Shared Memory Parallel Programming
What is jubatus (short)
Beyond Map/Reduce: Getting Creative With Parallel Processing
Tikal's Backbone_js introduction workshop
Play Framework and Activator
Plreuse
Enterprise Java Web Application Frameworks Sample Stack Implementation
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Perf onjs final
Static or Dynamic Typing? Why not both?
Booting into functional programming
Single Page Applications with AngularJS 2.0
4th European Lisp Symposium: Jobim: an Actors Library for the Clojure Program...
Jvm memory model
WebNet Conference 2012 - Designing complex applications using html5 and knock...
My first experience with lambda expressions in java
Functional programming for the Advanced Beginner
Implementing a JavaScript Engine
DjangoCon 2010 Scaling Disqus
Erjang - A journey into Erlang-land

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
Cloud computing and distributed systems.
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
Cloud computing and distributed systems.
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx

Introduction to Underscore.js