(1) What is the difference between what is a formal parameter in a JS function and what is an argument? Parameters are called parameter variables, and the variables received by the function in JS are divided into formal parameters and arguments. An argument is a specific data that is actually used to participate in a JS function call. A formal parameter is a variable that receives an argument value when the function is called. According to the actual needs, the formal parameters are optional, without formal parameters, the parentheses can not be omitted. When multiple parameters are present, the parameters are separated by commas. Instance:
window.onload=function() {function Compare (A, b) {return(a>b? A:B)}alert (compare (5,9));}
In the function compare (), A, B is the formal parameter, and the alert function enters an argument in the call to compare () 5,9. (2) What is the difference between variables and parameters in JS? The variable is the amount that the value is allowed to change during the program's run. A constant is the amount of value that is not allowed to change during a program's run. The JS variable is declared using the keyword var. Variable instance: var i,sum;//declare variable i,sum JS parameter is only for function call, parameter is the complement component of function. (3) What is an object in JavaScript? An object is a basic data type of JavaScript, and an object is a conforming value: it aggregates a number of values together, and these values are accessed by these names.
JavaScript arguments, parameters, and variables