Grammar format:
function functionname() { // execute code }
function is a keyword used to define a function.
Note: Javascript is case sensitive. The keyword function must be lowercase, and the function must be called with the same case as the function name.
Function with parameters
Grammar format:
function myFunction(var1,var2) { the code }
Example:
A parameter with a return value
The return value is realized by the return statement .
Grammar format:
function myFunction() { var x=5; return x; }
Note: Using the return statement does not mean that the entire Javascript stops executing, only the function. Javascript will continue to execute the code from where the function was called.
Example:
Recommended tutorial: js introductory tutorial
The above is how to understand the details of the function concept in Javascript, please pay attention to 1024programmer for more .com Other related articles!