[Template] Javascript Functions
Been dealing with Javascript functions lately, I find that these are the most-frequently-used input parameters for all a typical function: data url (optional) callback (optional) A good JS function should readily accept these parameters. And a typical Javascript function call would be like: somefunction( {data: value, data2: value2 }, [url], [callback()] ); We know that in PHP we can use the following method to write a "optional" second (or third) input parameter. function somefunction( $data, $callback = FALSE); This way, if the second argument is not supplied, $callback will be automatically assigned to FALSE . Its a good practice to set a default value for a variable. After Googling around, I found that Javascript is event better at handling such case. We can take in as many optional input parameters, in no specific order . But the trade-off is, we need a check for the input parameter type. Stackoverflow has this excellent post on the template for...