码迷,mamicode.com
首页 > 编程语言 > 详细

javascript 函数2_函数的参数的传递

时间:2015-02-07 14:22:06      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<!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>

  

javascript 函数2_函数的参数的传递

标签:

原文地址:http://www.cnblogs.com/aicpcode/p/4278697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!