SlideShare uma empresa Scribd logo
1 de 13
Object Oriented JavaScript
 JavaScript is a flexible                              Embrace the principles of
and expressive language                                    OO design and how
 that should be written                                prototypical languages like
 clearly and concisely.                                   JavaScript fit into this
                                                               paradigm.




                            JavaScript is one of the
                              cornerstones to the
                             powerful set of tools
                              made available by
                                   HTML5
Remember Why?

Just to name some of the reasons...
  Encapsulation
  Composition
  Inheritance
  Polymorphism
Prototype Based Language

No formal class defn.
Objects are prototypes
Inheritance through
  cloning
  ex nihilo "from nothing"
Instance Objects
BaseSoup = function() {
  name = "simple soup";
  price = 7.00;
  ingredients = ["water", "salt", "mirepoix"];
}

BaseSoup.prototype.menuDisplay = function() {
  return name.concat(" ").concat(price);
}

var soup = new BaseSoup();
soup.menuDisplay();
Composition, Private Methods...
BaseSoup = function() {
  name = "simple soup";
  priceMgr = new PriceManager();
  ingredients = ["water", "salt", "mirepoix"];
  price = function() {
     return priceMgr.price(this);
  }
}

BaseSoup.prototype.menuDisplay = function() {
  return name.concat(" ").concat(price());
}
Inheritance
CrabBisque = function() {};

//Lets inherit from the BaseSoup object from the previous slides
CrabBisque.prototype = new BaseSoup;
CrabBisque.prototype.constructor = CrabBisque;
CrabBisque.prototype.parent = BaseSoup.prototype;

CrabBisque.prototype.description = function() {
  return "Delicious crab in a rich cream broth";
}

var bisque = new CrabBisque();
bisque.menuDisplay();
Polymorphic Jackpot
CrabBisque = function() {
   name = "Crab Bisque";
   ingredients = ["salt", "mirepoix",
                       "heavy cream", "crab", "butter",
                        "leeks", "pepper", "tomato paste"];
};

CrabBisque.prototype = new BaseSoup;
CrabBisque.prototype.constructor = CrabBisque;
CrabBisque.prototype.parent = BaseSoup.prototype;

var bisque = new CrabBisque();
bisque.display();
bisque.description();
Soup? Inspiration.
call ~ super
CrabBisque = function() {
   BaseSoup.call(this); //call the super object constructor
   name = "Crab Bisque";
   ingredients = ["salt", "mirepoix",
                       "heavy cream", "crab", "butter"
                        "leeks", "pepper", "tomato paste"];
};

CrabBisque.prototype.description = function() {
  return BaseSoup.prototype.description.call(this); //call the super method
}
"From Nothing"
var lunch = {soup: new Jambalaya(), bread: true,
 drink: "Coke", burp: function() { return "yum"}};
Static Objects
SoupFactory = (function() {
  return {
     serve: function(person) {
       switch(person.name()) {
           case "Newman":
             return new Jambalaya();
           case "George":
             return new CrabBisque();
           case "Elaine":
             return new Mulligatawny();
           default:
             return new LimaBean();
       }
     }
  }

})();
Closures / Anonymous Functions
//function in a function
//retains a copy of the local variable despite being an anon function
FatCat = function() {
   var weight = 4;
   this.eat = function() { weight++; };
   this.weighIn = function() { alert(weight); };
   this.speak = function() {
      kittyTalk = function() { alert(meow); }
      //NOTE: meow is defined _after_ the anon above...it still works!
      var meow = "Meeeooww";
      return kittyTalk; //just got functional
   }
}
Functional Sprinkles of Goodness
function each(arrayOfStuff, action) {

    for(var i = 0; i < arrayOfStuff.length; i++) {
       action(arrayOfStuff[i]);
    }

}

each([1,2,3,4,5], alert);

Mais conteúdo relacionado

Destaque

Let's earn some media by Jelle Kolleman, Red Urban
Let's earn some media by Jelle Kolleman, Red UrbanLet's earn some media by Jelle Kolleman, Red Urban
Let's earn some media by Jelle Kolleman, Red UrbanHyves
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery Dmitry Buzdin
 
Making Pretty Charts in Splunk
Making Pretty Charts in SplunkMaking Pretty Charts in Splunk
Making Pretty Charts in SplunkSplunk
 
Red Urban presenteert succesvolle Hyvescampagnes & learnings
Red Urban presenteert succesvolle Hyvescampagnes & learnings Red Urban presenteert succesvolle Hyvescampagnes & learnings
Red Urban presenteert succesvolle Hyvescampagnes & learnings Hyves
 
An ASAP Validation Implementation Approach by Qualit Consulting
An ASAP Validation Implementation Approach by  Qualit ConsultingAn ASAP Validation Implementation Approach by  Qualit Consulting
An ASAP Validation Implementation Approach by Qualit Consultingaesww
 

Destaque (6)

MongoDB Part 2
MongoDB Part 2MongoDB Part 2
MongoDB Part 2
 
Let's earn some media by Jelle Kolleman, Red Urban
Let's earn some media by Jelle Kolleman, Red UrbanLet's earn some media by Jelle Kolleman, Red Urban
Let's earn some media by Jelle Kolleman, Red Urban
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Making Pretty Charts in Splunk
Making Pretty Charts in SplunkMaking Pretty Charts in Splunk
Making Pretty Charts in Splunk
 
Red Urban presenteert succesvolle Hyvescampagnes & learnings
Red Urban presenteert succesvolle Hyvescampagnes & learnings Red Urban presenteert succesvolle Hyvescampagnes & learnings
Red Urban presenteert succesvolle Hyvescampagnes & learnings
 
An ASAP Validation Implementation Approach by Qualit Consulting
An ASAP Validation Implementation Approach by  Qualit ConsultingAn ASAP Validation Implementation Approach by  Qualit Consulting
An ASAP Validation Implementation Approach by Qualit Consulting
 

Semelhante a Object Oriented JavaScript: Embrace OO Principles

JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascriptDoeun KOCH
 
Functional programming with Immutable .JS
Functional programming with Immutable .JSFunctional programming with Immutable .JS
Functional programming with Immutable .JSLaura Steggles
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Roy Yu
 
Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009tolmasky
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming PrimerMike Wilcox
 
Chaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreChaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreNicolas Carlo
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02plutoone TestTwo
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suckerockendude
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScriptNone
 

Semelhante a Object Oriented JavaScript: Embrace OO Principles (20)

Javascript
JavascriptJavascript
Javascript
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
Functional programming with Immutable .JS
Functional programming with Immutable .JSFunctional programming with Immutable .JS
Functional programming with Immutable .JS
 
Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101Javascript Testing with Jasmine 101
Javascript Testing with Jasmine 101
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
Prototype
PrototypePrototype
Prototype
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
 
Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009Cappuccino @ JSConf 2009
Cappuccino @ JSConf 2009
 
test
testtest
test
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
 
Chaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscoreChaining et composition de fonctions avec lodash / underscore
Chaining et composition de fonctions avec lodash / underscore
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suck
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 

Último

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Último (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Object Oriented JavaScript: Embrace OO Principles

  • 1. Object Oriented JavaScript JavaScript is a flexible Embrace the principles of and expressive language OO design and how that should be written prototypical languages like clearly and concisely. JavaScript fit into this paradigm. JavaScript is one of the cornerstones to the powerful set of tools made available by HTML5
  • 2. Remember Why? Just to name some of the reasons... Encapsulation Composition Inheritance Polymorphism
  • 3. Prototype Based Language No formal class defn. Objects are prototypes Inheritance through cloning ex nihilo "from nothing"
  • 4. Instance Objects BaseSoup = function() { name = "simple soup"; price = 7.00; ingredients = ["water", "salt", "mirepoix"]; } BaseSoup.prototype.menuDisplay = function() { return name.concat(" ").concat(price); } var soup = new BaseSoup(); soup.menuDisplay();
  • 5. Composition, Private Methods... BaseSoup = function() { name = "simple soup"; priceMgr = new PriceManager(); ingredients = ["water", "salt", "mirepoix"]; price = function() { return priceMgr.price(this); } } BaseSoup.prototype.menuDisplay = function() { return name.concat(" ").concat(price()); }
  • 6. Inheritance CrabBisque = function() {}; //Lets inherit from the BaseSoup object from the previous slides CrabBisque.prototype = new BaseSoup; CrabBisque.prototype.constructor = CrabBisque; CrabBisque.prototype.parent = BaseSoup.prototype; CrabBisque.prototype.description = function() { return "Delicious crab in a rich cream broth"; } var bisque = new CrabBisque(); bisque.menuDisplay();
  • 7. Polymorphic Jackpot CrabBisque = function() { name = "Crab Bisque"; ingredients = ["salt", "mirepoix", "heavy cream", "crab", "butter", "leeks", "pepper", "tomato paste"]; }; CrabBisque.prototype = new BaseSoup; CrabBisque.prototype.constructor = CrabBisque; CrabBisque.prototype.parent = BaseSoup.prototype; var bisque = new CrabBisque(); bisque.display(); bisque.description();
  • 9. call ~ super CrabBisque = function() { BaseSoup.call(this); //call the super object constructor name = "Crab Bisque"; ingredients = ["salt", "mirepoix", "heavy cream", "crab", "butter" "leeks", "pepper", "tomato paste"]; }; CrabBisque.prototype.description = function() { return BaseSoup.prototype.description.call(this); //call the super method }
  • 10. "From Nothing" var lunch = {soup: new Jambalaya(), bread: true, drink: "Coke", burp: function() { return "yum"}};
  • 11. Static Objects SoupFactory = (function() { return { serve: function(person) { switch(person.name()) { case "Newman": return new Jambalaya(); case "George": return new CrabBisque(); case "Elaine": return new Mulligatawny(); default: return new LimaBean(); } } } })();
  • 12. Closures / Anonymous Functions //function in a function //retains a copy of the local variable despite being an anon function FatCat = function() { var weight = 4; this.eat = function() { weight++; }; this.weighIn = function() { alert(weight); }; this.speak = function() { kittyTalk = function() { alert(meow); } //NOTE: meow is defined _after_ the anon above...it still works! var meow = "Meeeooww"; return kittyTalk; //just got functional } }
  • 13. Functional Sprinkles of Goodness function each(arrayOfStuff, action) { for(var i = 0; i < arrayOfStuff.length; i++) { action(arrayOfStuff[i]); } } each([1,2,3,4,5], alert);