Functions in JavaScript-7

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.