The method for declaring a function in javascript and the return value for calling the function.

Source: Internet
Author: User

The method for declaring a function in javascript and the return value for calling the function.

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

What is the return value of javascript Functions? What are the functions?

Funcion is the English name of a function. Use this to declare a variable. The returned value is to return the variable to be called with a column: function func (a, B) // declare a function named func. the function has two variables a and B (which can also be values) {// the code of the function starts from {and ends from} x = a * B // you can apply for a formula by yourself. apply. a + B a % B can return x // return the value of x, that is, the variable that calls this formula} // Function Code ends var num = func) // This is the variable num that calls the func function, inherits the formula in func, and gives a = 1, B = 2. the Return Value of the above function is returned here. after calling the formula in func, the value of the variable num is a * B, that is, 2*3. So the value of num is 6.

What is the return value of javascript Functions? What are the functions?

A function is an event-driven or reusable code block that is executed when it is called.

Compile the script as a function to avoid executing the script when loading the page.

A function contains code that can only be executed when an event is activated or called.

You can call the script anywhere on the page (if the function is embedded with an external. js file, you can even call it from other pages ).

The following are related details:
Www.w3school.com.cn/js/js_functions.asp

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.