Pairing
The inclusion of a function argument actually matches the definition of the scope of the variable (in other words, it is actually the same as defining a link at the function level using the var keyword). The main reason for providing function arguments (in JavaScript) is for your own interface.
arguments object
Arguments can still be passed to functions without parameters and will still be available in the 'hidden' arguments object, which is a kind of “pseudo-array” (if you want), because it is a functionally array, but not equipped with the same APIs JavaScript is equipped with Array (pseudo-type) interfaces:
// The following functions do the same thing, but one is "more readable" function foo() { return arguments; } function bar(baz, qux) { return arguments; }
Evaluation (interface) vs Execution (implementation)
When both functions are evaluated (in the "load" file), the arguments object is undefined in each function definition; the object does not become “defined” until the function body executes the code in it; to visualize what using pseudo-code it would look something like this:
// Function bodies (as objects) foo : { arguments : new Array // [undefined] __proto__ : Empty() // the super-object that allows this object to inherit "functionality" } bar : { arguments : new Array(baz, qux) // [undefined, undefined] __proto__ : Empty() }
Function call
Therefore, when you call a function, it "implements" or "executes" its body (its "object"). When this happens, if the objects that were placed in the arguments object are defined, the function can refer to them. If not, a reference error will be selected that registers undefined variables in this area.
In short:
There is no need to bind scope level variables (like "private members") with var , because the language already attaches the arguments object to the whole body of function objects.
Additional Information:
Jamming JavaScript: A "caching function" of several arguments for better performance: http://decodize.com/javascript/javascript-memoization-caching-results-for-better-performance/