I am used to seeing a few basic variations on handling optional variables. Sometimes, the relaxed versions are useful.
function foo(a, b, c) {
a = a || "default"; // Matches 0, "", null, undefined, NaN, false.
a || (a = "default"); // Matches 0, "", null, undefined, NaN, false.
if (b == null) { b = "default"; } // Matches null, undefined.
if (typeof c === "undefined") { c = "default"; } // Matches undefined.
}
The falsy default used with variable a is, for example, used extensively in Backbone.js.