If there is more than one argument to de specified then we separate them with commas. The arguments are then used within the function just as if they were variables but they are not, they are just substitute names for the variables that we will tell the function to use when we actually run it.
function writeSentence(argument1,argument2) {
document.write('The '+argument1+' is '+argument2+'.<br />');
}
Passing Values as Parameters
You don't have to define a variable to pass as a parameter to a function. You can pass values directly provided that the function is only going to use the value and is not expected to be able to change it.
As the "a" variable always contains "table" in our example above, we don't need to define this variable if we are only going to use the value in our function call. We can instead pass the value as the parameter instead of a variable containing the value.
We do it like this:
writeSentence('table',b);
You can pass any combination of variables and values as parameters to a function that does not update the value passed to it.
Premalatha
Software Engineer
Bhagwati, if this helps please login to Mark As Answer. | Alert Moderator