JavaScript basic Syntax Serial (read these basically understand)

Source: Internet
Author: User

1. Functions

Functions are important to any language, and the core knowledge points

1.function Sayhi (name,message) {    alert ("Hello" + name + "," + message);          } 2.sayHi ("Jyxs", "Well done!");

Look at the code first:

1. Describes the definition of the function, defined by the keyword function + functions name + parameter {

}

(The function named by the Hump naming method, the first letter to lowercase, not uppercase, otherwise become a constructor, although the same structure, but at this time as a distinction, we understand as a normal function can be)

2. The function can have a return value, or it can return without return value.

3. The parameters of the function are different from the other function parameters, the ECMAScript function does not mind how many arguments are passed, the parameters are simply facilitated, not required, the parameters are stored in the arguments object, the length property of the parameter in arguments is determined by the parameters passed in. , which is not determined by the number of named parameters when the function is defined.

4. Functions are objects, each function is an instance of a function type, and the function name is simply a pointer to a functional object and is not bound to a function. So the following statement is the same.

function sum (num1,num2) {  return num1+num2;  } var sum = function (num1,num2) {return num1+num2;} ;

There is also a way to define a function that is defined with a constructor function

var sum =  new Function ("Num1", "num2", "return num1+num2");

But this method of definition is not recommended because it results in two parsing, which affects performance.

JavaScript basic Syntax Serial (read these basically understand)

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.