Create manner: 1, function f () {}
2, var obj = new Function ( "parameter 1", "parameter n", "function body")
After the first load execution
The number of parameters f.length
Function call:
arguments can get all the parameters
Anonymous function: 1, var func = function (arg) {} func ()
2、(function(arg)){alert(arg)})("Yuan")
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> //// 函数的创建方式一 // // // function f(x,y) { // alert(123); // return x+y; //null // } // console.log(f(23,5678)); // // // foo ( "blind ass"); // function foo (name, Age) { // the console.log ( "Hello" + name) // } // // // // Create a function of two ways // // // var obj = new new Function ( "name", "the console.log (\" Hello \ "+ name)") // obj ( "Wu"); // // the console.log (foo.length) // // // call the function // // // function the Add (X, Y, Z) { // return X + Y + Z // } // // the console.log (the Add (1,2, 3,4,5,6)); // console.log(add(1,2)); // console.log(add("hello","world")); // 面试题 // function f(x,y) { // return x+y // } // // var f=1; // var b=2; // f(f,b) // arguments // function f() { // console.log(arguments); // // return a+b // } // f(1,2,45,6,7,78); // function ADD() { // var sum=0; // for (var i=0;i<arguments.length;i++){ // sum+=arguments[i] // } // return sum // } // // console.log(ADD(1,2)) // 匿名函数 // var func = function(arg){ // alert(arg) // }; // // func("hello"); (function(arg){ alert(arg) })("YUAN") </script> </body> </html>