with Imagination: by Dustin Diaz

./with Imagination

A JavaScript, CSS, XHTML web log focusing on usability and accessibility by Dustin Diaz

Scoping anonymous functions

Tuesday, May 6th, 2008

This is obviously a no-brainer in that knowing something like this works in JavaScript, but it never really occurred to me to even do such a thing until today. Take the following example which ‘calls’ the anonymous function within a unique scope:

Scoping anonymous funcitons

var o = 'hello world';

(function() {
  alert(this);
}).call(o);

It seems ridiculous (in a good way), but it works!

Continue reading | 15 Comments

JavaScript Video Tutorial Screencasts

Learn the fundementals of the Yahoo! User Interface utilities and how to add progressive enhancements to your webpages with only applying the basics.
Download QT Movie (19MB)

Learn how to add Ajax to your website using the Yahoo! UI Connection Manager with minimal code and maximum flexibility.
Download QT Movie (31MB)

Learn how to write a client-side Web Service API in JavaScript using Object Oriented methodologies along with a best-practices approach that will allow you to play nice with the other JavaScript kids in your neighborhood.
Download QT Movie (19MB)

Podcasts

Episode 16: A fictional JavaScript tale

This episode was done solo as I tell a fictional tale about five JavaScript kids (among others) that I wrote during a night I wasn’t able to get any sleep. It features a few of the greatest JavaScripters around as the characters including the following:

Episode 15: Venni viddi vicci of Events

Justin Palmer in many ways felt like the brother I never had even though I will claim to have other JavaScript mafia brothers as well.

Aside from that matter, the “Experience Engineer” from Encytemedia (and Prototype enthusiast) and I spoke about the various forms of Events that all encompass JavaScript. And indeed; we came, we saw, and we conquered.

About ./with Imagination

Butterfly

Hi, my name is Dustin Diaz and I am a User Interface Engineer for Gooooogle and author of JavaScript Design Patterns. This is my website. Welcome!

On this site I write about JavaScript; I have some podcasts; I also have a few screencasts for those of you who are visual learners. All that aside, if you learn something from me: Excellent. I appreciate you dropping by.

If you have any more interest in learning more about what I do, how long I've been doing it, or how to get a hold of me, you can do that on the about page. Cheers.

Get "JavaScript Design Patterns"

"As a web developer, you'll already know that JavaScript™ is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power waiting to be unlocked--JavaScript is capable of full object-oriented capabilities, and by applying OOP principles, best practices, and design patterns to your code, you can make it more powerful, more efficient, and easier to work with alone or as part of a team."

Buy JS Design Patterns from Amazon.com Buy JS Design Patterns from Apress

All content copyright © 2003 - 2007 under the Creative Commons License. Wanna know something? Just ask.

About | Archives | Blog Search

[x] close

Loading...

Submit a prototype

By checking this prototype I agree that I am not submitting false credentials, pornography, or a hate crime website. I also understand that by submitting my entry I may or may not be accepted, and if accepted, my entry may be taken down at any given time if I violate these terms.