11
Underscore .js Moohanad Hassan Maedeh Pishvae

Underscore.js

  • Upload
    carina

  • View
    56

  • Download
    0

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

Page 1: Underscore.js

Underscore.js

Moohanad HassanMaedeh Pishvae

Page 2: Underscore.js

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

Page 3: Underscore.js

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

Page 4: Underscore.js

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.

Page 5: Underscore.js

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

Page 6: Underscore.js

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

Page 7: Underscore.js

Underscore Complements jQuery

• Complements jQuery by its functional support– Collections– Arrays– Functions– Objects– Utilities

http://aveic.ru/underscorejs/cheatsheet.pdf

Page 8: Underscore.js

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

Page 9: Underscore.js

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

Page 10: Underscore.js

RESOURCESDocumentation:http://documentcloud.github.com

Good Libraries Reduce the Burden