Java Script function

Source: Internet
Author: User

Java Script function

definition; a function is an event-driven or reusable block of code that executes when it is invoked.

Basic format; Functionname (formal parameter) {code block}. Call function----------function name (argument);

Knowledge point; 1. The parameters that are accepted by the function are controlled by the actual parameter;

column;   function stt (x, y) {return arguments.length;}

document.write (STT (1,2,3,4));

The result is 4.

    2. when the formal parameter has a default value and there is no incoming parameter, the function accepts the parameter as the default value of the formal parameter. Arguments that are accepted when an argument is passed in are arguments.

function STT (x=1,y=2) {return x+y; }

document.write (STT ());

The result is 3;

document.write (STT (3,4));

The result is 7;

Explanation: Arguments is an array of system writes, and window is an object that gets global.

Java Script 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.