It is often useful to create functions with the variable number of arguments: if the argument is not specified, it automatically gets a default value.
Here is how to do it:
function MyFun(a, b, c)
{
a = (typeof(a) == "undefined") ? false : a;
b = (typeof(b) == "undefined") ? 50 : b;
c = (typeof(c) == "undefined") ? "Some text" : c;
// Do something with a,b,c
}
DamienD
Visit us at
Here is how to do it:
function MyFun(a, b, c)
{
a = (typeof(a) == "undefined") ? false : a;
b = (typeof(b) == "undefined") ? 50 : b;
c = (typeof(c) == "undefined") ? "Some text" : c;
// Do something with a,b,c
}
DamienD
Visit us at