change this to:
if (typeof format == 'undefined') {
Some browsers have historically not enjoyed the direct comparison to undefined.  It might still throw an undefined error for comparing directly against a variable that is undefined.  The logic will still work.  Go with typeof as the string comparison is less volatile and won't have the chance of throwing an error in the console.