javascript function parameters or variables or arguments -- are these three the same?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

I've used the jQuery function to create jQuery objects by including the selector inside the parentheses as the function's arguments or parameters or variable i.e.:

Code:

$("div").css("color", "blue");

and it seems very obvious to me what is going on and why the selectors are within the parentheses of these functions. However, when I need to create a function or if I am reading someone else's code where they are creating their own custom native javascript functions. I don't know why it is so hard for me to understand.

This function gives names to four parameters that it expects to be passed when the function is called - these also exist inside the function but also exist outside the function (but not necessarily with the same names)

You use parameters with a function when you want to pass information to the function that can be different each time the function is called. Variables defined inside the function are created when the function starts running and are deleted when that execution of the function funushes.

In the code above, a, b and c are parameters or arguments to the calculateAverage function. And total and average are local variables to the function. And the function is called 3 times with different set of parameters/arguments generating different results. Actually, a, b, c, total and average are all local variables. The difference is that for a, b, c variables, the default values are specified outside the function when that function is invoked with values passed to it.

The code in red is passing a single object to the function, the code in green is passing THREE strings to the function. The function expects three strings to be passed and not one object and so does not work if an object is passed instead of the three strings.