首页 > 其他 > 详细

函数传参的具体用法

时间:2017-09-24 21:49:26      阅读:326      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <script type="text/javascript">
            //参数 = js的数据类型(基本类型和引用类型)
            //数字.字符串.布尔.函数.对象.未定义.数组
            fnc(100);
            fnc(stlying);
            fnc(function() {
                alert(222);
            });
            function fnc(e) {
                if(typeof e === number && e === e) {
                    alert(e + 5)
                } else if(typeof e === string) {
                    alert(e.charAt(3))
                } else if(typeof e === function) {
                    e();
                }
            }            
            //例子
            fun(window,document);
            function fun(win,doc){
                win.onload = function(){
                    doc.body.innerHTML ="你好,js";
                }        
            }
            //return返回值
            alert(fn())  //return ==>等价于fn()==>100
            function fn(){
                return 100
            }
            //传的参数只能一一对应
        </script>
    </body>
</html>

 

函数传参的具体用法

原文:http://www.cnblogs.com/lhl66/p/7588803.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!