SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Más de 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
 

Más de 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
 

Último

8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCRashishs7044
 
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
 
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCRashishs7044
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menzaictsugar
 
(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
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfJos Voskuil
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy Verified Accounts
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdfKhaled Al Awadi
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessSeta Wicaksana
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
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
 
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 Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCRashishs7044
 
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
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxMarkAnthonyAurellano
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Timedelhimodelshub1
 
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
 
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
 

Último (20)

8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
8447779800, Low rate Call girls in Kotla Mubarakpur Delhi NCR
 
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
 
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR8447779800, Low rate Call girls in Tughlakabad Delhi NCR
8447779800, Low rate Call girls in Tughlakabad Delhi NCR
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
 
(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
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
 
Buy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail AccountsBuy gmail accounts.pdf Buy Old Gmail Accounts
Buy gmail accounts.pdf Buy Old Gmail Accounts
 
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdfNewBase  19 April  2024  Energy News issue - 1717 by Khaled Al Awadi.pdf
NewBase 19 April 2024 Energy News issue - 1717 by Khaled Al Awadi.pdf
 
Organizational Structure Running A Successful Business
Organizational Structure Running A Successful BusinessOrganizational Structure Running A Successful Business
Organizational Structure Running A Successful Business
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In 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
 
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 Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR8447779800, Low rate Call girls in Saket Delhi NCR
8447779800, Low rate Call girls in Saket Delhi NCR
 
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
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
Call Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any TimeCall Girls Miyapur 7001305949 all area service COD available Any Time
Call Girls Miyapur 7001305949 all area service COD available Any Time
 
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?
 
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

Notas del editor

  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?