+ 2
Is arguments in JS Function a kind of variable?
Hi, I'm little confused about arguments in JavaScript function. I think it works like variables. Am I right?
3 odpowiedzi
+ 1
Kind of
Inside the functional scope, argument works like a variable.
When you make changes to an argument, if it is a primitive type, the original variable is not affected.
If the argument is object or array, the original variable is affected.
If you don't use argument to pass values into function, and use a global variable, changes in functional scope will affect the global variable.
- 1
the correct term is “parameter” except, it doesnt need to be to be declared in the parenthesis () of the function to be accessible within the function.