Basic description of JS function

Source: Internet
Author: User

1. Creation of functions

in the the keyword for creating functions inside JavaScript is function

Function Name: It is the identifier that needs to be written when we call the functions

Formal parameter: All called formal parameters, when calling a function, what are the parameters required for this function?

Arguments: All called actual parameters, when the function is called, the parameters actually passed to the function

Call to function

The method is very simple, just write the function name, followed by a pair of parentheses. Note that you need to write parentheses whenever you call a function, regardless of whether it is a parameter or not.

2. parameters of the function

(1) parameter names of parameters can be repeated, parameter parameters of the same name take the last value

(2) even if a function declares a formal parameter, it can be called without passing the argument value

(3) when calling a function, you can pass several argument values to the function, regardless of the number of parameters required by the formal parameter declaration .

Inside the function, there is a pseudo-array object. The so-called pseudo-array refers to arrays that look like arrays, but are not really.

We can use the array method to test whether the arguments is an array

Its role is to store the arguments that pass over.

3. return value of function

when the function is finished, we can return a value and return the value of the keyword .

It is important to note that once the function is run to return, the function is finished. In other words, The statement after return is not executed

Return can only return one number at a time, but if you want to return multiple numbers, put multiple numbers in the array and return to the array.

Basic description of JS function

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.