Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Created June 2, 2013 03:09
Show Gist options
  • Save IQAndreas/5692481 to your computer and use it in GitHub Desktop.
Save IQAndreas/5692481 to your computer and use it in GitHub Desktop.
Unless I am mistaken, FireFox allows optional parameters in functions, Chrome does not.
<script type="text/javascript">
function optional(required, optional = 5)
{
console.log(required, optional);
}
optional("a", "b");
optional("c");
optional();
</script>
/* ----------------------------------
All sample outputs are on Ubuntu 13.04 (though as all browsers are cross-platform, it shouldn't matter anyway)
> Mozilla FireFox 21.0
a b
c 5
undefined 5
> Google Chrome 27.0.1453.93
Uncaught SyntaxError: Unexpected token =
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment