1 <html lang="en"> 2 <head> 3 <meta charset="utf-8" /> 4 <title>路书</title> 5 </head> 6 <body> 7 <script> 8 //动态函数调用,调用者使用"myFunc" 9 function myFunc() 10 { 11 alert(11111); 12 return 9; 13 } 14 15 test("myFunc"); 16 17 function test(funcName) 18 { 19 if(typeof(eval(funcName)) == "function") 20 { 21 var s = eval(funcName+"();"); 22 alert(s); 23 } 24 else 25 { 26 // 函数不存在 27 } 28 } 29 </script> 30 <script> 31 /** 32 * 声明一个函数 33 * @explain 传参个数不确定 34 */ 35 function test() { 36 for (var i = 0; i < arguments.length; i++) { 37 //var param = arguments[i]; 38 eval("var param" + (i + 1).toString() + "= arguments[" + i + "]"); 39 } 40 alert(param1); 41 alert(param2); 42 alert(param3); 43 } 44 // 调用 45 test('Marydon','http://www.cnblogs.com','动态创建变量演示'); 46 </script> 47 </body> 48 </html>
https://jsbin.com/halesotuva/edit?html,output
https://github.com/login?client_id=43726f23784354889899&return_to=%2Flogin%2Foauth%2Fauthorize%3Fclient_id%3D43726f23784354889899%26redirect_uri%3D%26response_type%3Dcode%26scope%3Duser%253Aemail%252Cgist