How to test if a parameter is provided to a function?

后端 未结 8 1058
不知归路
不知归路 2020-12-13 03:45

I was wondering, can you create a function with an optional parameter.

Example:

function parameterTest(test)
{
   if exists(test)
   {
     alert(\'t         


        
8条回答
  •  不知归路
    2020-12-13 03:52

    function parameterTest(p) {
        if ( p === undefined)
            alert('The parameter doesn\'t exist...');
        else
            alert('the parameter exists...');
    }
    

提交回复
热议问题