Alex, about the “arg = arg || ‘howdy’;” or “arg = arg || { foo:123 };” notation… It’s not really a problem that it doesn’t work if arg is 0, because you don’t use it in a situation like that. It’s mostly useful for optional objects or arrays, so there is no ambiguity around the “false” value. It also can be useful for optional strings, as long as you’re aware that “” will be treated as “false”.

About “self” vs. “that”: What browser is confused by “self”? It is not a reserved word or anything magic. It is simply a property of the window object. In other words, the browser has done the equivalent of:

window.self = window;

If you use a variable named “self” inside a function, it should not be confused with this global “self”. Perhaps Doug’s choice of “that” is just to avoid *programmer* confusion?

About the “typeof foo == ‘undefined'”, I prefer doing this:

// At the top of the .js file, to support very old browsers
window.undefined = window.undefined;

Now you can code this in any browser:

if( foo === undefined ) whatever;

In many cases, however, you don’t really need to distinguish between null and undefined values, so this is sufficient:

if( foo ==null ) whatever;