SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Anything But Typical Learning to Love JavaScript Prototypes Page 1© 2010 Razorfish. All rights reserved. Dan Nichols March 14, 2010
JavaScript Page 2© 2010 Razorfish. All rights reserved.
Object-Oriented Programming Page 3© 2010 Razorfish. All rights reserved.
class Page 4© 2010 Razorfish. All rights reserved.
Inheritance Page 5© 2010 Razorfish. All rights reserved.
prototype(not the library) Page 6© 2010 Razorfish. All rights reserved.
The story so far… Page 7© 2010 Razorfish. All rights reserved.
<a onclick=“javascript:alert(‘chaos!’)”> Page 8© 2010 Razorfish. All rights reserved.
Page 9© 2010 Razorfish. All rights reserved.
…except it wasn’t all good. Page 10© 2010 Razorfish. All rights reserved.
Page 11© 2010 Razorfish. All rights reserved.
Page 12© 2010 Razorfish. All rights reserved.
Page 13© 2010 Razorfish. All rights reserved.
Page 14© 2010 Razorfish. All rights reserved.
Sound familiar? Page 15© 2010 Razorfish. All rights reserved.
Page 16© 2010 Razorfish. All rights reserved. prototype(not the library) to the rescue!
Page 17© 2010 Razorfish. All rights reserved. Everything is an object
Page 18© 2010 Razorfish. All rights reserved. Every object has a prototype
Page 19© 2010 Razorfish. All rights reserved. prototypes do good things
Page 20© 2010 Razorfish. All rights reserved. Encourage modularityand reusability
Page 21© 2010 Razorfish. All rights reserved. Provide a consistent wayto do (different) things
Page 22© 2010 Razorfish. All rights reserved. Keep code to a minimum
Page 23© 2010 Razorfish. All rights reserved. Make complexity easy
What is a prototype, exactly? Page 24© 2010 Razorfish. All rights reserved.
Page 25© 2010 Razorfish. All rights reserved. A reference point for other objects
Property lookup chain Page 26© 2010 Razorfish. All rights reserved.
Property lookup chain Page 27© 2010 Razorfish. All rights reserved. instance Date Object
Property lookup chain Page 28© 2010 Razorfish. All rights reserved. instance Date Object
Property lookup chain Page 29© 2010 Razorfish. All rights reserved. instance Date Object
Property lookup chain Page 30© 2010 Razorfish. All rights reserved. instance Date Object
Page 31© 2010 Razorfish. All rights reserved. JavaScript is different frommost other OOP languages
Anatomy of a prototype Page 32© 2010 Razorfish. All rights reserved. rex Poodle Dog Object
Anatomy of a prototype Page 33© 2010 Razorfish. All rights reserved. Constructor
Anatomy of a prototype Page 34© 2010 Razorfish. All rights reserved. Property Method
Anatomy of a prototype Page 35© 2010 Razorfish. All rights reserved. Constructor Inheritance
Anatomy of a prototype Page 36© 2010 Razorfish. All rights reserved. Instance Instance Property
this and the lookup chain Page 37© 2010 Razorfish. All rights reserved. fluffy socks Cat Object
this and the lookup chain Page 38© 2010 Razorfish. All rights reserved. socks Cat Object
this and the lookup chain Page 39© 2010 Razorfish. All rights reserved. fluffy Cat Object
Execution context: this and call() Page 40© 2010 Razorfish. All rights reserved.
Execution context: this and call() Page 41© 2010 Razorfish. All rights reserved.
Execution context with instances Page 42© 2010 Razorfish. All rights reserved. Same outcome
Page 43© 2010 Razorfish. All rights reserved. Inheritance
Working with inherited behavior Page 44© 2010 Razorfish. All rights reserved. LimitedContainer Container Object
Working with inherited behavior Page 45© 2010 Razorfish. All rights reserved. LimitedContainer Container Object
Working with inherited behavior Page 46© 2010 Razorfish. All rights reserved. LimitedContainer Container Object
Page 47© 2010 Razorfish. All rights reserved. JavaScript is the Frankensteinof the OOP world
Borrowing from multiple prototypes Page 48© 2010 Razorfish. All rights reserved.
Page 49© 2010 Razorfish. All rights reserved. One small problem
The constructor problem Page 50© 2010 Razorfish. All rights reserved.
The constructor problem Page 51© 2010 Razorfish. All rights reserved.
Fixing the constructor problem Page 52© 2010 Razorfish. All rights reserved.
Fixing the constructor problem Page 53© 2010 Razorfish. All rights reserved.
Page 54© 2010 Razorfish. All rights reserved. prototype isn’t love at first sight
Page 55© 2010 Razorfish. All rights reserved. Putting prototypes to work
Requirements ,[object Object]
Required
Email
Number
Zip Code
 Multiple rules can apply to one field
 Rules need to be inferred from  data-rich, standard HTML

Weitere ähnliche Inhalte

Andere mochten auch

ClientSummit2010_EricJillard(Mercedes)
ClientSummit2010_EricJillard(Mercedes)ClientSummit2010_EricJillard(Mercedes)
ClientSummit2010_EricJillard(Mercedes)Razorfish
 
ClientSummit2010_MikeBoylson(JCPenney)
ClientSummit2010_MikeBoylson(JCPenney)ClientSummit2010_MikeBoylson(JCPenney)
ClientSummit2010_MikeBoylson(JCPenney)Razorfish
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook ReportRazorfish
 
Razorfish & CafeMom - Digital Mom
Razorfish & CafeMom - Digital MomRazorfish & CafeMom - Digital Mom
Razorfish & CafeMom - Digital MomRazorfish
 
Sleeping Giants: Digital Awakens TV and Media
Sleeping Giants: Digital Awakens TV and MediaSleeping Giants: Digital Awakens TV and Media
Sleeping Giants: Digital Awakens TV and MediaRazorfish
 
ClientSummit2010_JohanJervoe(Intel)
ClientSummit2010_JohanJervoe(Intel)ClientSummit2010_JohanJervoe(Intel)
ClientSummit2010_JohanJervoe(Intel)Razorfish
 
Razorfish outlook report 2011 (vol10)
Razorfish outlook report 2011 (vol10)Razorfish outlook report 2011 (vol10)
Razorfish outlook report 2011 (vol10)Luis Miranda
 
Fluent: The Razorfish Social Influence Marketing Report
Fluent: The Razorfish Social Influence Marketing ReportFluent: The Razorfish Social Influence Marketing Report
Fluent: The Razorfish Social Influence Marketing ReportRazorfish
 
Creative Sponge - Agency Credentials
Creative Sponge - Agency CredentialsCreative Sponge - Agency Credentials
Creative Sponge - Agency Credentialsalextosh
 

Andere mochten auch (9)

ClientSummit2010_EricJillard(Mercedes)
ClientSummit2010_EricJillard(Mercedes)ClientSummit2010_EricJillard(Mercedes)
ClientSummit2010_EricJillard(Mercedes)
 
ClientSummit2010_MikeBoylson(JCPenney)
ClientSummit2010_MikeBoylson(JCPenney)ClientSummit2010_MikeBoylson(JCPenney)
ClientSummit2010_MikeBoylson(JCPenney)
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook Report
 
Razorfish & CafeMom - Digital Mom
Razorfish & CafeMom - Digital MomRazorfish & CafeMom - Digital Mom
Razorfish & CafeMom - Digital Mom
 
Sleeping Giants: Digital Awakens TV and Media
Sleeping Giants: Digital Awakens TV and MediaSleeping Giants: Digital Awakens TV and Media
Sleeping Giants: Digital Awakens TV and Media
 
ClientSummit2010_JohanJervoe(Intel)
ClientSummit2010_JohanJervoe(Intel)ClientSummit2010_JohanJervoe(Intel)
ClientSummit2010_JohanJervoe(Intel)
 
Razorfish outlook report 2011 (vol10)
Razorfish outlook report 2011 (vol10)Razorfish outlook report 2011 (vol10)
Razorfish outlook report 2011 (vol10)
 
Fluent: The Razorfish Social Influence Marketing Report
Fluent: The Razorfish Social Influence Marketing ReportFluent: The Razorfish Social Influence Marketing Report
Fluent: The Razorfish Social Influence Marketing Report
 
Creative Sponge - Agency Credentials
Creative Sponge - Agency CredentialsCreative Sponge - Agency Credentials
Creative Sponge - Agency Credentials
 

Ähnlich wie Anything But Typical: Learning to Love JavaScript Prototypes

The Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersThe Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersPeter-Paul Koch
 
JavaScript: You Like It, It Likes You
JavaScript: You Like It, It Likes YouJavaScript: You Like It, It Likes You
JavaScript: You Like It, It Likes YouScott Kosman
 
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...Peter Hecker
 
Lotico oct 2010
Lotico oct 2010Lotico oct 2010
Lotico oct 2010dallemang
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법guestad13b55
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013Stuart Myles
 
Google ARが提供する WebAR 101
Google ARが提供する WebAR 101Google ARが提供する WebAR 101
Google ARが提供する WebAR 101Hirokazu Egashira
 
Real-time Semantic Web with Twitter Annotations
Real-time Semantic Web with Twitter AnnotationsReal-time Semantic Web with Twitter Annotations
Real-time Semantic Web with Twitter AnnotationsJoshua Shinavier
 
Securing Web Applications
Securing Web ApplicationsSecuring Web Applications
Securing Web Applicationsgoodfriday
 
Finding harmony in web development
Finding harmony in web developmentFinding harmony in web development
Finding harmony in web developmentChristian Heilmann
 
Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Alex Cachia
 
Web browsers & the realtime web
Web browsers & the realtime webWeb browsers & the realtime web
Web browsers & the realtime webPhil Leggetter
 
JavaScript Internationalization I18n for Efficient Software Localization
JavaScript Internationalization I18n for Efficient Software LocalizationJavaScript Internationalization I18n for Efficient Software Localization
JavaScript Internationalization I18n for Efficient Software LocalizationLingoport (www.lingoport.com)
 
Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)srigi
 

Ähnlich wie Anything But Typical: Learning to Love JavaScript Prototypes (20)

The Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The BrowsersThe Ajax Experience: State Of The Browsers
The Ajax Experience: State Of The Browsers
 
JavaScript: You Like It, It Likes You
JavaScript: You Like It, It Likes YouJavaScript: You Like It, It Likes You
JavaScript: You Like It, It Likes You
 
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
 
Lotico oct 2010
Lotico oct 2010Lotico oct 2010
Lotico oct 2010
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법주로사용되는 Xss필터와 이를 공격하는 방법
주로사용되는 Xss필터와 이를 공격하는 방법
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013
 
Google ARが提供する WebAR 101
Google ARが提供する WebAR 101Google ARが提供する WebAR 101
Google ARが提供する WebAR 101
 
Real-time Semantic Web with Twitter Annotations
Real-time Semantic Web with Twitter AnnotationsReal-time Semantic Web with Twitter Annotations
Real-time Semantic Web with Twitter Annotations
 
Securing Web Applications
Securing Web ApplicationsSecuring Web Applications
Securing Web Applications
 
Adobemax2009na
Adobemax2009naAdobemax2009na
Adobemax2009na
 
Finding harmony in web development
Finding harmony in web developmentFinding harmony in web development
Finding harmony in web development
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)
 
Python basics
Python basicsPython basics
Python basics
 
Web browsers & the realtime web
Web browsers & the realtime webWeb browsers & the realtime web
Web browsers & the realtime web
 
JavaScript Internationalization I18n for Efficient Software Localization
JavaScript Internationalization I18n for Efficient Software LocalizationJavaScript Internationalization I18n for Efficient Software Localization
JavaScript Internationalization I18n for Efficient Software Localization
 
Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)Webpack & EcmaScript 6 (Webelement #32)
Webpack & EcmaScript 6 (Webelement #32)
 
Look beyond PHP
Look beyond PHPLook beyond PHP
Look beyond PHP
 

Mehr von Razorfish

ClientSummit2010_HendersonPetrillo(SkilletStreetFood)
ClientSummit2010_HendersonPetrillo(SkilletStreetFood)ClientSummit2010_HendersonPetrillo(SkilletStreetFood)
ClientSummit2010_HendersonPetrillo(SkilletStreetFood)Razorfish
 
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)Razorfish
 
ClientSummit2010_RussellTaylor(AxeCaseStudies)
ClientSummit2010_RussellTaylor(AxeCaseStudies)ClientSummit2010_RussellTaylor(AxeCaseStudies)
ClientSummit2010_RussellTaylor(AxeCaseStudies)Razorfish
 
ClientSummit2010_MediaMixWorkshop
ClientSummit2010_MediaMixWorkshopClientSummit2010_MediaMixWorkshop
ClientSummit2010_MediaMixWorkshopRazorfish
 
ClientSummit2010_SearchWorkshop
ClientSummit2010_SearchWorkshopClientSummit2010_SearchWorkshop
ClientSummit2010_SearchWorkshopRazorfish
 
ClientSummit2010_CloudWorkshop
ClientSummit2010_CloudWorkshopClientSummit2010_CloudWorkshop
ClientSummit2010_CloudWorkshopRazorfish
 
ClientSummit2010_AgileWorkshop
ClientSummit2010_AgileWorkshopClientSummit2010_AgileWorkshop
ClientSummit2010_AgileWorkshopRazorfish
 
ClientSummit2010_MobileWorkshop
ClientSummit2010_MobileWorkshopClientSummit2010_MobileWorkshop
ClientSummit2010_MobileWorkshopRazorfish
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook ReportRazorfish
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook ReportRazorfish
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook ReportRazorfish
 
A Decade in Search
A Decade in SearchA Decade in Search
A Decade in SearchRazorfish
 
Social Influence Marketing Trends
Social Influence Marketing TrendsSocial Influence Marketing Trends
Social Influence Marketing TrendsRazorfish
 
FEED: The Razorfish Digital Brand Experience Report 2009 Key Findings
FEED: The Razorfish Digital Brand Experience Report 2009 Key FindingsFEED: The Razorfish Digital Brand Experience Report 2009 Key Findings
FEED: The Razorfish Digital Brand Experience Report 2009 Key FindingsRazorfish
 
FEED: The Razorfish Digital Brand Experience Report 2009
FEED: The Razorfish Digital Brand Experience Report 2009FEED: The Razorfish Digital Brand Experience Report 2009
FEED: The Razorfish Digital Brand Experience Report 2009Razorfish
 
Highlights From Fluent
Highlights From FluentHighlights From Fluent
Highlights From FluentRazorfish
 
Design Matters: A Mobile UX Manifesto
Design Matters: A Mobile UX ManifestoDesign Matters: A Mobile UX Manifesto
Design Matters: A Mobile UX ManifestoRazorfish
 

Mehr von Razorfish (17)

ClientSummit2010_HendersonPetrillo(SkilletStreetFood)
ClientSummit2010_HendersonPetrillo(SkilletStreetFood)ClientSummit2010_HendersonPetrillo(SkilletStreetFood)
ClientSummit2010_HendersonPetrillo(SkilletStreetFood)
 
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)
ClientSummit2010_MathiasSinn(McDonalds-NeueDigitale)
 
ClientSummit2010_RussellTaylor(AxeCaseStudies)
ClientSummit2010_RussellTaylor(AxeCaseStudies)ClientSummit2010_RussellTaylor(AxeCaseStudies)
ClientSummit2010_RussellTaylor(AxeCaseStudies)
 
ClientSummit2010_MediaMixWorkshop
ClientSummit2010_MediaMixWorkshopClientSummit2010_MediaMixWorkshop
ClientSummit2010_MediaMixWorkshop
 
ClientSummit2010_SearchWorkshop
ClientSummit2010_SearchWorkshopClientSummit2010_SearchWorkshop
ClientSummit2010_SearchWorkshop
 
ClientSummit2010_CloudWorkshop
ClientSummit2010_CloudWorkshopClientSummit2010_CloudWorkshop
ClientSummit2010_CloudWorkshop
 
ClientSummit2010_AgileWorkshop
ClientSummit2010_AgileWorkshopClientSummit2010_AgileWorkshop
ClientSummit2010_AgileWorkshop
 
ClientSummit2010_MobileWorkshop
ClientSummit2010_MobileWorkshopClientSummit2010_MobileWorkshop
ClientSummit2010_MobileWorkshop
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook Report
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook Report
 
2010 Razorfish Outlook Report
2010 Razorfish Outlook Report2010 Razorfish Outlook Report
2010 Razorfish Outlook Report
 
A Decade in Search
A Decade in SearchA Decade in Search
A Decade in Search
 
Social Influence Marketing Trends
Social Influence Marketing TrendsSocial Influence Marketing Trends
Social Influence Marketing Trends
 
FEED: The Razorfish Digital Brand Experience Report 2009 Key Findings
FEED: The Razorfish Digital Brand Experience Report 2009 Key FindingsFEED: The Razorfish Digital Brand Experience Report 2009 Key Findings
FEED: The Razorfish Digital Brand Experience Report 2009 Key Findings
 
FEED: The Razorfish Digital Brand Experience Report 2009
FEED: The Razorfish Digital Brand Experience Report 2009FEED: The Razorfish Digital Brand Experience Report 2009
FEED: The Razorfish Digital Brand Experience Report 2009
 
Highlights From Fluent
Highlights From FluentHighlights From Fluent
Highlights From Fluent
 
Design Matters: A Mobile UX Manifesto
Design Matters: A Mobile UX ManifestoDesign Matters: A Mobile UX Manifesto
Design Matters: A Mobile UX Manifesto
 

Kürzlich hochgeladen

PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationAnamaria Contreras
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607dollysharma2066
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaoncallgirls2057
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...ShrutiBose4
 
MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?Olivia Kresic
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCRashishs7044
 
8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCRashishs7044
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncrdollysharma2066
 
Future Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionFuture Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionMintel Group
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailAriel592675
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Kirill Klimov
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesKeppelCorporation
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMVoces Mineras
 
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadIslamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadAyesha Khan
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...ictsugar
 

Kürzlich hochgeladen (20)

PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement Presentation
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
 
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City GurgaonCall Us 📲8800102216📞 Call Girls In DLF City Gurgaon
Call Us 📲8800102216📞 Call Girls In DLF City Gurgaon
 
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
Ms Motilal Padampat Sugar Mills vs. State of Uttar Pradesh & Ors. - A Milesto...
 
MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR
8447779800, Low rate Call girls in New Ashok Nagar Delhi NCR
 
8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
 
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCREnjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
 
Future Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted VersionFuture Of Sample Report 2024 | Redacted Version
Future Of Sample Report 2024 | Redacted Version
 
Case study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detailCase study on tata clothing brand zudio in detail
Case study on tata clothing brand zudio in detail
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
Annual General Meeting Presentation Slides
Annual General Meeting Presentation SlidesAnnual General Meeting Presentation Slides
Annual General Meeting Presentation Slides
 
Memorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQMMemorándum de Entendimiento (MoU) entre Codelco y SQM
Memorándum de Entendimiento (MoU) entre Codelco y SQM
 
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in IslamabadIslamabad Escorts | Call 03070433345 | Escort Service in Islamabad
Islamabad Escorts | Call 03070433345 | Escort Service in Islamabad
 
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...Global Scenario On Sustainable  and Resilient Coconut Industry by Dr. Jelfina...
Global Scenario On Sustainable and Resilient Coconut Industry by Dr. Jelfina...
 

Anything But Typical: Learning to Love JavaScript Prototypes

Hinweis der Redaktion

  1. Web was a scary placeBrowser compatibility and features all over the mapDevs hop from site to site grabbing snippets of code
  2. JS libraries emerge several years agoSmooth over cross browser differencesMake complex behavior easyProvide frameworks for enhancement
  3. New dependency on libraries and plugins is growingDevs spend a lot of time… (series)
  4. Searching for a JS library extension that does what they need
  5. Changing site to fit what the extension does
  6. Brute-force coding requirements back in
  7. Live in fear of repeating it allwhen make updateson the next project
  8. One of JS most powerful featues goesUnusedIgnoredMisunderstoodAnd it can help
  9. JS is OOP language
  10. Objects are containers forProperties - DataMethods - BehaviorsWork with objects all the time
  11. Template for properties + methodsWork with prototypes every dayEven if you don’t realize itDate, Array, etc
  12. Code you writeCode loaded in memory
  13. Easy to…BuildModifyExpand on complex interactions
  14. Reference point that serves as basis for an objectTo understand prototypeNeed to understand property lookup chain
  15. Simple exampleCreate a date var named “instance”Define a new property on the varCall several methods
  16. PLC for instance var looks like thisInstance prototype = DateDate prototype = ObjectJS uses PLC to find values of referenced properties
  17. Look up instance.fooJS finds it on the var itselfStops looking
  18. Lookup instance.getTimeDoesn’t find it on the varFinds it on DateStops looking
  19. Lookup instance.hasOwnPropertyDoesn’t find it on varDoesn’t find it on DateFinds it on Object
  20. Prototypes are put together different than most
  21. More complicated exampleRex is var instance of PoodlePoodle prototype = DogDog prototype = Object
  22. Closer look at DogFunctionAll functions have prototype propertyPrototype defaults to ObjectConstructor is Function paired with NEW operatorUsed to create instances
  23. Dog’s prototype property used to build the templateFunctions on a prototype are methodsNon-functions on a prototype are propertiesAnything defined on function’s prototype available to instances
  24. Poodle is second typeFunction, just like DogInheritanceSet Poodle.prototype to new instance of DogCreates link between Poodle and Dog in PLCCreate properties on Poodle.prototypeAvailable to instances of Poodle
  25. Rex is instance of PoodleProperty “name” defined on rex – instance propertyHas access to all of Poodle’s prototype propertiesAnd to other properties up PLC
  26. Probably recognize THIS operatorLook at how THIS interacts with prototypeIn example:Socks and fluffy both instances of CatCat inherits from Object
  27. When call socks.speakFinds speak property on Cat.prototypeInside of speak, encounter THISProperties on THIS walk PLC starting at instanceGreeting not a property of socks instanceGreeting is a property of Cat prototype
  28. When call fluffy.speakSpeak function found on Cat.prototype, same as socksUnlike socks, fluffy has own greeting propertylookup stops at instance
  29. Functions have call method that lets set execution contextTHIS operator refers back to execution context
  30. When sayFoo called with exec context objTHIS = obj
  31. Calling a method on an instance is same asUsing CALL to supply instance as exec context prototype method
  32. Shown some basic examples so far, but don’t really take advantageDive deeper into inheritance
  33. In example:Container type hasarray that it can store items inMethod to add itemsinherits from ObjectLimitedContainerInherits from ContainerChanges inherited behavior to limit how many items can be in array
  34. Behavior in Container constructor creates items arrayTo get LC to also have that behaviorCALL Container constructor with THIS as exec context within LC constructor
  35. Container’s addItem method just pushes into arrayWant to set a limit to how many items can be in arrayDefine new addItem method on LC prototypeThe new addItem is higher in the PLC, so it will be found before old oneAdd logic into new method to throw error if there are too many itemsCALL Container’s addItem method with THIS as exec context to get original behavior
  36. Have kind of a patchwork natureCan take advantage of that to bring together lots of complicated behaviors
  37. In example, CatDog borrows behavior from Cat and DogCat instances are furious when call swim methodDog instances are delightedCatDog is both delighted and furious when you call its swim method
  38. May have noticed an issue in earlier examples
  39. Have two types: Parent and ChildChild inherits from parent
  40. When Child linked to ParentParent constructor is calledParent constructor has undesirable behaviorAlert goes off when set up inheritance
  41. Get around issue with a simple helper function
  42. Helper:Creates intermediate function that does nothingAssigns parent prototype to itInstantiates intermediate as prototypeBecause prototype is same b/t intermediate and parent, PLC stays intactAlso define constructor on child while we’re at itNo more undesirable behavior
  43. Prototypes have never been accused of being very prettyBut they are very powerful
  44. Up to now, haven’t had any real world examplesLet’s see what they can really doEXAMPLEPretty standard HTML formCommon problem is validating a formLet’s do it with prototypes!
  45. Helper:Creates intermediate function that does nothingAssigns parent prototype to itInstantiates intermediate as prototypeBecause prototype is same b/t intermediate and parent, PLC stays intactAlso define constructor on child while we’re at itNo more undesirable behavior
  46. Helper:Creates intermediate function that does nothingAssigns parent prototype to itInstantiates intermediate as prototypeBecause prototype is same b/t intermediate and parent, PLC stays intactAlso define constructor on child while we’re at itNo more undesirable behavior
  47. And do a really good job of itStart to get into trouble when depend totally on the libraryStart to get into bad trouble when depending totally on plugins
  48. Easy to…BuildModifyExpand on complex interactions
  49. Help you design the interactionthe way it needs to workand in a reusable, extensible way that plays well with others
  50. Any questions?