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)