Home > Web Front-end > JS Tutorial > body text

JavaScript Enhancement Tutorial - Function Parameters

巴扎黑
Release: 2016-12-05 11:34:57
Original
1115 people have browsed it

This article is the official HTML5 training tutorial of H5EDU organization. It mainly introduces: JavaScript enhancement tutorial - function parameters

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 parameter:
Example

function myFunction(x, y) { 
    if (y === undefined) { 
          y = 0; 
    } 
}
Copy after login


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!