A function, in essence, is a form of grouping of code. We can give a name to a group of code in this form, so that later reuse is called.
function sum (b) { var c = A +b ; return C;}
1. A function can have only one return value, and if we need to return more than one value at a time, consider putting it in an array and returning it as an array element.
2. We can create some functions that are more flexible in terms of the number of parameters. This is thanks to a built-in arguments array within each function that returns all the parameters accepted by the function.
3. Functions are actually objects, each of which is an instance of a function type, with properties and methods. Therefore, the function name is actually a pointer to the function object.
4. Function declaration:
function sum (num1,num2) { return num1+num2 }
Or
var sum=function(num1,num2) { return num1+num2; };
Or
var sum=New// not recommended
No overloads in 5.JavaScript
funtion Add (num) { return num + 100< Span style= "color: #000000;" >; } funtion Add (num) { return num + 200;} var result=add (100); // 300 // Think of the function name as a pointer, this example declares two functions of the same name, and the latter overwrites the preceding function, which is equivalent to funtion Add (num) { return num + 100; } Add (num) { return num + 200 var result=add (100); // 300
6.this refers to the scope at which the function executes.
7. Each function contains: length and prototype. The Length property represents the number of arguments the function expects to receive.
function Sayname (name) { function sum (num1,num2) { return num1+num2;} Funtion Sayhi () { alert ("HI");} alert (sayname.length); // alert (sum.length); // alert (Sayhi (). length); // 0
Reference:
Http://www.cnblogs.com/zxj159/archive/2013/05/17/3084579.html
3. Function functions