Mike West — Web Application Developer

I’ve got a new article in the latest issue of Digital Web, diving deeply into JavaScript’s concepts of scope and execution context.

Scope in JavaScript was originally an ode to the single most useful piece of the Prototype framework — the bind method. I wanted to discuss in detail how bind makes it possible to have interesting and readable object-oriented code, while at the same time embracing event handlers and setTimeout to control your code’s execution. The issue is simply that event handlers execute your code in a context outside your objects, which makes the this keyword confusing at best, and flat-out wrong at worst. bind is an elegant solution to the problem, and the article concludes with a deep dive into a simplified version of that function to tease out exactly what it does, and how it works.

I found, however, that the article was mostly incomprehensible to those without a firm grounding in the issues of scope and execution context, and the lesser-known ways of manipulating execution context (apply and call). In an effort to give that audience something to sink their teeth into, I added a good amount of discussion of the basic concepts of scope, and what an execution context really means. I hope I’ve struck a good balance between the two, and that the article builds a solid foundation as it goes.

If you’re interested in this sort of thing, read Scope in JavaScript, and let me know what you think. The comments should be interesting. :)

Mike West is a web application developer living in Munich, Germany. Professionally programming for the web since 2000, he's available for contract work now a web developer at Yahoo! Germany. Read Mike's bio, or drop him an e-mail.

Recent Articles


Comments

Trackback:
http://blog.ginader.de/archives/2006/09/12/Gueltigkeitsbereiche-in-JavaScript.php
Scope in JavaScript heisst der neueste Artikel im Digital Web Magazine. Mike West erklärt darin in sehr anschaulicher Art und Weise die Gültigkeitsbereiche (Scope) in JavaScript. Jeder Entwickler hat sich schon (mindestens) einmal gewundert, warum…

Posted By: Dirk Ginader 12. September 2006, 17:16

your article is very helpfull, it’s explanation are clear and understandable for newbies like me ^^

*greetings from indonesia ^^

Posted By: qureyoon 13. September 2006, 09:11

Comments Closed

Comments are closed after 6 weeks to avoid the icky comment spam we all loathe. Sorry if you missed the opportunity, but you can always drop me an e-mail!

flickr Photostream

Yahoo!'s Munich Office
atom:title
atom:title
atom:title