JavaScript arguments, parameters, and variables

Source: Internet
Author: User

(1) What is the difference between what is a formal parameter in a JS function and what is an argument? Parameters are called parameter variables, and the variables received by the function in JS are divided into formal parameters and arguments. An argument is a specific data that is actually used to participate in a JS function call. A formal parameter is a variable that receives an argument value when the function is called. According to the actual needs, the formal parameters are optional, without formal parameters, the parentheses can not be omitted. When multiple parameters are present, the parameters are separated by commas. Instance:
window.onload=function() {function  Compare (A, b) {return(a>b?  A:B)}alert (compare (5,9));}
In the function compare (), A, B is the formal parameter, and the alert function enters an argument in the call to compare () 5,9. (2) What is the difference between variables and parameters in JS? The variable is the amount that the value is allowed to change during the program's run. A constant is the amount of value that is not allowed to change during a program's run. The JS variable is declared using the keyword var.  Variable instance: var i,sum;//declare variable i,sum JS parameter is only for function call, parameter is the complement component of function. (3) What is an object in JavaScript? An object is a basic data type of JavaScript, and an object is a conforming value: it aggregates a number of values together, and these values are accessed by these names.

JavaScript arguments, parameters, and variables

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.