WordPress Websites for Engineers: Elevate Your Brand
Write Better JavaScript
1. Write Better JavaScript Kevin Whinnery Engineer and Platform Evangelist Appcelerator, Inc. @kevinwhinnery
2. Kevin Whinnery Engineer and Platform Evangelist Appcelerator since 2008 Husband and father of three: Web developer and JavaScript slinger turned mobile and desktop hacker. http://kevinwhinnery.com http://twitter.com/kevinwhinnery http://github.com/kwhinnery
39. JavaScript has Prototypal Inheritance, which creates new copies of objects from an existing object (the prototype) there’s much more to it than this, but we’ll keep it mostly high level…
43. …but object instantiation using the prototype to define functions/properties is faster. http://ejohn.org/blog/simple-class-instantiation mentions this and other methods for…
45. JavaScript doesn’t support multiple inheritance, but there are multiple libraries that handle that and more, including underscore.js http://documentcloud.github.com/underscore/#extend
46.
47. Add new features and functionality to it (the parasites, if you will)
A closure is a function, with a referencing environment for the free variables (arguments) to that function – it provides the function with a scope, that will live on for the life of the closure. It’s also the only way to create scope in JavaScript.