The arguments object in a function
There is a arguments inside each function that returns all the arguments that the function accepts
Note: The argumens is receiving an argument
The following is a summation function written using the arguments attribute:
function Sumonsteroids () {var I, res = 0;var Number_of_params = arguments.length;for (I = 0; I < Number_of_params; i++) { res + = Arguments[i];} return res;}
Ii. about the scope of variables
In JavaScript, you cannot define a specific block-level scope for a variable, but you can define the function domain to which it belongs.
Global variables in JavaScript refer to variables declared outside of all functions
A local variable defined inside a function that does not exist outside the function
If you declare a variable inside a function without using the VAR statement, the variable is defaulted to the global variable (even if it is externally defined in the function). This variable does not exist until the function is called, and is first created and given the global scope after the function is called.
Three, self-tuning function
A self-tuning function is a function that can be called itself after the definition, with the following basic structure:
{function (name) { alert (' Hello ' + name + '! ');}} (' Martin ')
Subsequent () arguments can be passed, and the values declared inside are automatically passed to the parameters of the function
Using such self-tuning anonymous functions as above will not produce any global variables
Iv. functions that can be rewritten on their own
This function is characterized by the ability to perform a function rewrite after execution, and here is an example:
function A () {alert ("a"); a = function () { alert ("B")};}
The first time a () is invoked, the alert ("a") is executed, and the second time A () is invoked, the alert ("B") is executed. Because the function was first executed, it redefined the global variable A
JavaScript basic knowledge Blind spot summary--function