I was wondering, can you create a function with an optional parameter.
Example:
function parameterTest(test)
{
if exists(test)
{
alert(\'t
This is a very frequent pattern.
You can test it using
function parameterTest(bool) {
if (bool !== undefined) {
You can then call your function with one of those forms :
parameterTest();
parameterTest(someValue);
Be careful not to make the frequent error of testing
if (!bool) {
Because you wouldn't be able to differentiate an unprovided value from false, 0 or "".