1.arguments is used to store the collection of transmission parameters, can be called multiple times, each time the group is different, enhancing the robustness of the function
Instance:
Function Calc () {
var sum = 0;
/* parameter is a time */
if (arguments.length = = 1) {
sum = arguments[0]
} else if (arguments.length = = 2) {
/* When the parameter is two */
for (var i = arguments[0]; I <= arguments[1]; i++) {
sum + = i;
}
}
return sum;
}
Console.log (calc); The//calc function can be called multiple times, and the number of arguments passed in can be different.
Console.log (Calc (10, 20));
2.This iscalled by the function who is this, the method is called when the function is preceded by a window, just omitted
var person = {};
Person.name = "fangming";
Person.cals = Calcone;
var resultone = Person.cals ();
function Calcone () {
Console.log (this);//This is the value inside the person array
var sum = 0;
for (var i = 0;i <= 10;i + +) {
Sum+=i;
}
return sum
}
Internal properties of JS inside function