Edit in JSFiddle

foo();
foo(1);
foo(2,3);


function foo(a, b)
 {
   a = typeof a !== 'undefined' ? a : 42;
   b = typeof b !== 'undefined' ? b : 'default_b';
   console.log(a + " " + b);
 }