<!DOCTYPE html> <html> <head> <title>javascript函数的传递</title> <script type="text/javascript"> function callFun(fun,arg){ //第一个参数是函数的对象 return fun(arg); } function sum(num){ return num+100; } function say(str){ alert("hello"+str); } //调用了say函数 callFun(say,"JACK"); //调用了sum函数 alert(callFun(sum,20)); function fn1(arg){ var rel = function(num){ return arg+num; } return rel; } var f = fn1(120); alert(f(20)); </script> </head> <body> </body> </html>
时间: 2024-10-11 01:17:48