SlideShare a Scribd company logo
Underscore & Backbone
Underscore
  Underscore is a utility belt for Javascript
Supports Functional Programming
Accessed as the '_' object

  _.is_NaN(...)

  _.extend(...)

  _.each(...)

Uses standard Javascript objects
Better Tests
● _.isNaN() - returns false with undefined

● _.isEqual() - full deep-compare, very

  efficient

● Standard form - _.isFunction, _.

  isString, _.isUndefined.
Extend for Mixins
_.extend(object, mixins)

● Works on any Javascript object

● Mixins are just standard JS objects too
{
  addon_function: function()....
  another_addon: function() ...
}
bind and bindAll
bind makes 'this' useful again

_.bind(function, context, [*args])

Returns a function that has a consistent 'this'
context.

_.bindAll(object) will bind all object's
properties with object as the context
Chain, Tap and Value
_.chain(value) returns a wrapped value,
which will stay wrapped until _.value() is
called

_([42, 43]).chain()
    .first()                                   // 42
    .take(function(val) { return val * 2 })   // 42 * 2
    .value()                                  // 84



_.tap() let's you temporarily unwrap the value
inside the chain
So Much More
● Safer keys, values, lastIndexOf,
  hasOwnProperty
● Array math (union, difference, sorting)
● Lightweight Templating
● All Under 4kb
Backbone Models
Backbone Models hold JSON data, typically
fetched from an external REST API

Backbone Models are defined with
Underscore's extend method

Backbone.Model.extend({
... model definition ...
});
Defaults
Backbone Models can define defaults which it
also borrows from Underscore

var Meal = Backbone.Model.extend({
  defaults: {
    "appetizer": "caesar salad",
    "entree":     "ravioli",
    "dessert":    "cheesecake"
  }
});
fetch/save
Calling fetch() on a Backbone Model is
analogous to a "GET" of that resource.

Calling save() is analogous to a "PUT"

model.fetch();
// make changes to model data
model.save();
Backbone.sync
All I/O on Backbone Models is done with
Backbone.sync

By default, Backbone.sync implements it's
CRUD methods on an AJAX backend.

There exist alternate implementations, such as
backbone.localStorage and backbone.
mongodb

Or you can write your own ...

More Related Content

What's hot

Backbonejs
BackbonejsBackbonejs
Backbonejs
Knoldus Inc.
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With Eclipse
Peter Friese
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core DataInferis
 
Js objects
Js objectsJs objects
Js objects
anubavam-techkt
 
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
DataStax Academy
 
Ruby on Rails Developer - Allerin
Ruby on Rails Developer - AllerinRuby on Rails Developer - Allerin
Ruby on Rails Developer - Allerin
Lauree R
 
React hooks
React hooksReact hooks
React hooks
Assaf Gannon
 
"this" in JavaScript
"this" in JavaScript"this" in JavaScript
"this" in JavaScript
Martha Schumann
 
Modular javascript
Modular javascriptModular javascript
Modular javascriptZain Shaikh
 
React Internals
React InternalsReact Internals
React Internals
Artur Skowroński
 
20190627 j hipster-conf- diary of a java dev lost in the .net world
20190627   j hipster-conf- diary of a java dev lost in the .net world20190627   j hipster-conf- diary of a java dev lost in the .net world
20190627 j hipster-conf- diary of a java dev lost in the .net world
Daniel Petisme
 
Multi-threaded CoreData Done Right
Multi-threaded CoreData Done RightMulti-threaded CoreData Done Right
Multi-threaded CoreData Done Right
morrowa_de
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
Akshay Mathur
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
This pointer .17
This pointer .17This pointer .17
This pointer .17myrajendra
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
Digesting jQuery
Digesting jQueryDigesting jQuery
Digesting jQuery
Mindfire Solutions
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
Natasha Murashev
 

What's hot (20)

Backbonejs
BackbonejsBackbonejs
Backbonejs
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With Eclipse
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
 
Js objects
Js objectsJs objects
Js objects
 
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
C* Summit EU 2013: Cassandra Made Simple with CQL Drivers and DevCenter
 
Ruby on Rails Developer - Allerin
Ruby on Rails Developer - AllerinRuby on Rails Developer - Allerin
Ruby on Rails Developer - Allerin
 
React hooks
React hooksReact hooks
React hooks
 
"this" in JavaScript
"this" in JavaScript"this" in JavaScript
"this" in JavaScript
 
Modular javascript
Modular javascriptModular javascript
Modular javascript
 
React Internals
React InternalsReact Internals
React Internals
 
20190627 j hipster-conf- diary of a java dev lost in the .net world
20190627   j hipster-conf- diary of a java dev lost in the .net world20190627   j hipster-conf- diary of a java dev lost in the .net world
20190627 j hipster-conf- diary of a java dev lost in the .net world
 
Multi-threaded CoreData Done Right
Multi-threaded CoreData Done RightMulti-threaded CoreData Done Right
Multi-threaded CoreData Done Right
 
Creating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JSCreating Single Page Web App using Backbone JS
Creating Single Page Web App using Backbone JS
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
This pointer .17
This pointer .17This pointer .17
This pointer .17
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Digesting jQuery
Digesting jQueryDigesting jQuery
Digesting jQuery
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 
Matreshka.js
Matreshka.jsMatreshka.js
Matreshka.js
 
Matreshka.js
Matreshka.jsMatreshka.js
Matreshka.js
 

Viewers also liked

East 55th & Euclid Avenue Crossroads Study Images
East 55th & Euclid Avenue Crossroads Study ImagesEast 55th & Euclid Avenue Crossroads Study Images
East 55th & Euclid Avenue Crossroads Study Images
MidTownCleInc
 
Bizim canımız çağıl hocamıza gelsin
Bizim canımız çağıl hocamıza gelsinBizim canımız çağıl hocamıza gelsin
Bizim canımız çağıl hocamıza gelsinÇağıl Kaya
 
A Rubyist Tries AngularJS
A Rubyist Tries AngularJSA Rubyist Tries AngularJS
A Rubyist Tries AngularJS
Kentucky JavaScript Users Group
 
mHealth regulations - Global efforts and readiness _White paper_DELL
mHealth regulations - Global efforts and readiness _White paper_DELLmHealth regulations - Global efforts and readiness _White paper_DELL
mHealth regulations - Global efforts and readiness _White paper_DELLSandesh Prabhu
 
PhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile AppsPhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile Apps
Kentucky JavaScript Users Group
 
Digital technologies are driving a new generation of telehealth_White paper_DELL
Digital technologies are driving a new generation of telehealth_White paper_DELLDigital technologies are driving a new generation of telehealth_White paper_DELL
Digital technologies are driving a new generation of telehealth_White paper_DELLSandesh Prabhu
 
Node and SocketIO
Node and SocketIONode and SocketIO
An Intro to AngularJS
An Intro to AngularJSAn Intro to AngularJS
An Intro to AngularJS
Kentucky JavaScript Users Group
 
JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013
Kentucky JavaScript Users Group
 

Viewers also liked (12)

East 55th & Euclid Avenue Crossroads Study Images
East 55th & Euclid Avenue Crossroads Study ImagesEast 55th & Euclid Avenue Crossroads Study Images
East 55th & Euclid Avenue Crossroads Study Images
 
Bizim canımız çağıl hocamıza gelsin
Bizim canımız çağıl hocamıza gelsinBizim canımız çağıl hocamıza gelsin
Bizim canımız çağıl hocamıza gelsin
 
Xerox mac
Xerox macXerox mac
Xerox mac
 
Mycv
MycvMycv
Mycv
 
A Rubyist Tries AngularJS
A Rubyist Tries AngularJSA Rubyist Tries AngularJS
A Rubyist Tries AngularJS
 
mHealth regulations - Global efforts and readiness _White paper_DELL
mHealth regulations - Global efforts and readiness _White paper_DELLmHealth regulations - Global efforts and readiness _White paper_DELL
mHealth regulations - Global efforts and readiness _White paper_DELL
 
PhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile AppsPhoneGap - JavaScript for Mobile Apps
PhoneGap - JavaScript for Mobile Apps
 
Digital technologies are driving a new generation of telehealth_White paper_DELL
Digital technologies are driving a new generation of telehealth_White paper_DELLDigital technologies are driving a new generation of telehealth_White paper_DELL
Digital technologies are driving a new generation of telehealth_White paper_DELL
 
Node and SocketIO
Node and SocketIONode and SocketIO
Node and SocketIO
 
An Intro to AngularJS
An Intro to AngularJSAn Intro to AngularJS
An Intro to AngularJS
 
JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013
 
Gok turks
Gok turksGok turks
Gok turks
 

Similar to Underscore and Backbone Models

JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
Jairam Chandar
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
Bruno Scopelliti
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
Make School
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
Neelkanth Sachdeva
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Backbone js
Backbone jsBackbone js
Backbone js
Knoldus Inc.
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
kvangork
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
Sebastian Pederiva
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
JavaScript Execution Context
JavaScript Execution ContextJavaScript Execution Context
JavaScript Execution Context
Juan Medina
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
scalaconfjp
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
Howard Lewis Ship
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Knoldus Inc.
 

Similar to Underscore and Backbone Models (20)

JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
Play 2.0
Play 2.0Play 2.0
Play 2.0
 
ECMAScript 2015
ECMAScript 2015ECMAScript 2015
ECMAScript 2015
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
JavaScript Execution Context
JavaScript Execution ContextJavaScript Execution Context
JavaScript Execution Context
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 

Recently uploaded

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 

Recently uploaded (20)

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

Underscore and Backbone Models

  • 2. Underscore Underscore is a utility belt for Javascript
  • 3. Supports Functional Programming Accessed as the '_' object _.is_NaN(...) _.extend(...) _.each(...) Uses standard Javascript objects
  • 4. Better Tests ● _.isNaN() - returns false with undefined ● _.isEqual() - full deep-compare, very efficient ● Standard form - _.isFunction, _. isString, _.isUndefined.
  • 5. Extend for Mixins _.extend(object, mixins) ● Works on any Javascript object ● Mixins are just standard JS objects too { addon_function: function().... another_addon: function() ... }
  • 6. bind and bindAll bind makes 'this' useful again _.bind(function, context, [*args]) Returns a function that has a consistent 'this' context. _.bindAll(object) will bind all object's properties with object as the context
  • 7. Chain, Tap and Value _.chain(value) returns a wrapped value, which will stay wrapped until _.value() is called _([42, 43]).chain() .first() // 42 .take(function(val) { return val * 2 }) // 42 * 2 .value() // 84 _.tap() let's you temporarily unwrap the value inside the chain
  • 8. So Much More ● Safer keys, values, lastIndexOf, hasOwnProperty ● Array math (union, difference, sorting) ● Lightweight Templating ● All Under 4kb
  • 9. Backbone Models Backbone Models hold JSON data, typically fetched from an external REST API Backbone Models are defined with Underscore's extend method Backbone.Model.extend({ ... model definition ... });
  • 10. Defaults Backbone Models can define defaults which it also borrows from Underscore var Meal = Backbone.Model.extend({ defaults: { "appetizer": "caesar salad", "entree": "ravioli", "dessert": "cheesecake" } });
  • 11. fetch/save Calling fetch() on a Backbone Model is analogous to a "GET" of that resource. Calling save() is analogous to a "PUT" model.fetch(); // make changes to model data model.save();
  • 12. Backbone.sync All I/O on Backbone Models is done with Backbone.sync By default, Backbone.sync implements it's CRUD methods on an AJAX backend. There exist alternate implementations, such as backbone.localStorage and backbone. mongodb Or you can write your own ...