Optional Parameters - Extending Existing Functions

Both PHP and javascript allow optional parameters and variable arguments.

PHP

javascript

  • The arguments sent to a function in javascript can be accessed as function_name.arguments. To find out how many arguments were passed, you can use function_name.arguments.length. http://www.w3schools.com/jS/js_functions.asp
  • Implementing default arguments with javascript can be done by using the arguments array.