Home > Web Front-end > JS Tutorial > JavaScript Enhancement Tutorial - Function Parameters

JavaScript Enhancement Tutorial - Function Parameters

巴扎黑
Release: 2016-12-06 13:34:49
Original
1071 people have browsed it

JavaScript function parameters
JavaScript functions do not perform any checks on the values ​​of parameters (arguments).
Function explicit parameters and hidden parameters (arguments)
In the previous tutorial, we have learned about the explicit parameters of the function:
functionName(parameter1, parameter2, parameter3) {
code to be executed
}
Explicit function parameters Listed when the function is defined.
Function hidden parameters (arguments) are the real values ​​passed to the function when the function is called.
Parameter Rules
The parameters do not specify data types when defining JavaScript functions.
JavaScript function does not detect hidden parameters (arguments).
The JavaScript function does not detect the number of hidden parameters (arguments).
Default parameters
If a function is called without parameters, the parameters will be set to: undefined by default
Sometimes this is acceptable, but it is recommended to set a default value for the parameters:
Example
function myFunction(x, y) {
if (y === undefined) {
  y = 0;
}
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template