1 / 62

Anything But Typical

Anything But Typical. Learning to Love JavaScript Prototypes. Dan Nichols March 14 , 2010. JavaScript. Object-Oriented Programming. class. Inheritance. prototype (not the library). The story so far…. <a onclick =“ javascript:alert (‘chaos!’)”>. …except it wasn’t all good.

austin
Télécharger la présentation

Anything But Typical

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Anything But Typical Learning to Love JavaScript Prototypes Dan Nichols March 14, 2010

  2. JavaScript

  3. Object-Oriented Programming

  4. class

  5. Inheritance

  6. prototype(not the library)

  7. The story so far…

  8. <a onclick=“javascript:alert(‘chaos!’)”>

  9. …except it wasn’t all good.

  10. Sound familiar?

  11. prototype(not the library) to the rescue!

  12. Everything is an object

  13. Every object has a prototype

  14. prototypes do good things

  15. Encourage modularityand reusability

  16. Provide a consistent wayto do (different) things

  17. Keep code to a minimum

  18. Make complexity easy

  19. What is a prototype, exactly?

  20. A reference point for other objects

  21. Property lookup chain

  22. Property lookup chain instance Date Object

  23. Property lookup chain instance Date Object

  24. Property lookup chain instance Date Object

  25. Property lookup chain instance Date Object

  26. JavaScript is different frommost other OOP languages

  27. Anatomy of a prototype rex Poodle Dog Object

  28. Anatomy of a prototype Constructor

  29. Anatomy of a prototype Property Method

  30. Anatomy of a prototype Constructor Inheritance

  31. Anatomy of a prototype Instance Instance Property

  32. this and the lookup chain socks fluffy Cat Object

  33. this and the lookup chain socks Cat Object

  34. this and the lookup chain fluffy Cat Object

  35. Execution context: this and call()

  36. Execution context: this and call()

  37. Execution context with instances Same outcome

  38. Inheritance

  39. Working with inherited behavior LimitedContainer Container Object

  40. Working with inherited behavior LimitedContainer Container Object

  41. Working with inherited behavior LimitedContainer Container Object

  42. JavaScript is the Frankensteinof the OOP world

  43. Borrowing from multiple prototypes

  44. One small problem

  45. The constructor problem

More Related