A pen test to think about, usually no one will modify the parameter values inside the function. Here, there are three ways to change the discussion.
1, directly modify the function declaration when the formal parameters
Copy Code code as follows:
Function F1 (a) {
alert (a);
A = 1;//modified parameter A
Alert (1 = = = a);
Alert (1 = = arguments[0]);
}
F1 (10);
Function F1 defines parameter A, calls newsletters parameter 10, pops up 10, modifies a 1, pops up two times true,a and Arguments[0] all 1.
2, through the function inside the arguments object modification
Copy Code code as follows:
function F2 (a) {
alert (a);
Arguments[0] = 1;//Modify Arguments
Alert (1 = = = a);
Alert (1 = = arguments[0]);
}
The effect is F1 with the function.
3, the local variable declared within the function has the same name as the formal parameter
Copy Code code as follows:
Function F3 (a) {
alert (a);
var a = 1;//declares local variable A and assigns a value of 1
Alert (1 = = = a);
Alert (arguments[0]);
}
F3 (10);
Function F3 defines the parameter a, the function declares local variable A at the same time assigns a value of 1, but here's a is still the argument a, from the last ejected Arguments[0] is modified to 1 can prove.
4, if you just declare the local variable a, but do not assign a value, the situation is different
Copy Code code as follows:
Function F3 (a) {
var a;//only declares, does not assign value
alert (a);
Alert (arguments[0]);
}
F3 (10);
This time the pop-up is 10, not undefined.