A good example says it all.
function foo(a, b) {
a = typeof a !== 'undefined' ? a : 42;
b = typeof b !== 'undefined' ? b : 'default_b';
// Do whatever you want
}
Done =)
Reference: StackOverflow – How do I make a default value for a parameter to a javascript function
