passing optional arguments in JavaScript

You can call a JavaScript object while passing an array of arguments with the method apply.

given:

function method(arg1, arg2){
  console.log([arg1, arg2]);
}

you can use:

method.apply(this, ['one', 'two']);
Jonathan Knapp