Pages

Wednesday, September 15, 2010

Javascript Optional Function argument

Let say you have a javascript function as follows
function jFunc( param1, param2, param3 )
{ 
// your function here…;
}

you can make the parameter of jFunc optional by using

if( param2 == undefined)
{
//do something here
}
if( param3 == undefined)
{
//do something here
} 

No comments:

Post a Comment