functions are also objects, and are a class-one citizen in JavaScript that can be used to create normal objects. Object is just a collection of properties and values
Learning Goals
1. mastering the role of functions
2. mastering the definition of functions
3. mastering the invocation of functions
Functions of the function
A function can encapsulate any number of statements, and can be invoked anywhere, at any time, to execute.
Definition of a function
The function uses functions, followed by a set of parameter-level function bodies,
The syntax is as follows:function functionname ([arg0,arg1,... argn]) {
Statements
}
Description: 1.functionName is the name of the function to be defined, which belongs to the identifier
2.[] arg0,arg1,... argn is the parameter of the function, it is not required
3.[] Just description of the content is not necessary, it is not a grammar
Function call
syntax: Name of function ([Arg1,arg2,... argn])
Learning Goals
Mastering the return value of a function
return value of the function
any function can implement the return value at any time through The return statement followed by the value to be returned.
Description
1. the function stops and exits immediately after executing the return statement.
The 2.Return statement can also be used without any return value, typically for the need to stop function execution prematurely without requiring
Returns the value of the case.
Learning Goals
Mastering Arguments
Arguments
The parameters in the ECMAScript are internally represented by an array, and the array parameters are accessed through the arguments object in the function body .
Description
1.arguments objects are just like arrays, not an instance of an array.
2.[] syntax to access every element of his.
The 3.Length property determines the number of pass parameters.
Functions in JavaScript-7