July 13, 2008
Author's Response:
An argument is just an "input" for a function, or at least that's how I like to think of it.
For example, if you have an "enemy" class, and have a function that spawns enemies, but want the strength of the enemies to depend on what difficulty the game is on, then you could define the spawn function with a difficulty argument:
function spawn (difficulty) {
if(difficulty == 3) {
//something;
}
}
then when you'd call the spawn function, you'd say:
spawn(3)
or
spawn(4)
and then the value in the parenthesis would get passed into the function under the variable name difficulty.