Upload
carina
View
56
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Underscore.js. Moohanad Hassan Maedeh Pishvae. OOP vs. Functional Programming?. OOP Fixed set of operation on things A s your code evolves, you add new things (like a class) FP F ixed set of things - PowerPoint PPT Presentation
Citation preview
Underscore.js
Moohanad HassanMaedeh Pishvae
OOP vs. Functional Programming?
OOP• Fixed set of operation on things• As your code evolves, you add new things (like a
class)FP
• Fixed set of things• As your code evolves, you add new operations (like a
function) on existing things
Functional Programming
JavaScript• Uses functions to turns one value into
another
• Taking a value, and returns a new value with no “side effect”
• Side effect: internal changes doesn’t affect outside of function
What is Underscore?
Underscore is a utility-belt library for JavaScript that provides a lot of the
functional programming support that you would expect in Ruby, but without extending any of the built-in JavaScript
objects.
JQuery
• jQuery does DOM (Document Object Model) manipulation and animation extremely well.
• DOM: Virtual map of webpage loaded on browser
• Most of jQuery functionality deals with the DOM, so it has little purpose outside the browser
jQuery and Underscore go hand in hand
• jQuery doesn’t deal with anything in the higher or lower levels
• For higher level: Backbone or Knockout
• For lower level: Underscore
Underscore Complements jQuery
• Complements jQuery by its functional support– Collections– Arrays– Functions– Objects– Utilities
http://aveic.ru/underscorejs/cheatsheet.pdf
Features
• No other dependencies
• Adds very little overhead to your total script
• Can be used on the client or server
• Good for MVC or non-DOM code
• Doesn’t modify built-in objects
Underscore Is Flexible
• Functional or Object-Oriented Style
• Chainable– Chain method tells Underscore to
return wrapped object– Value method returns the final at the
end
RESOURCESDocumentation:http://documentcloud.github.com
Good Libraries Reduce the Burden
Examples