arguments的简单用法

<script type="text/javascript">
        //Js中的函数可以不显式定义参数,arguments就是参数集合,在调用函数是传入了几个参数,
        //arguments集合就包含所有的传入参数,且参数顺序和传入顺序一致
        //js中的函数不需要显式的声明返回值
        function showHe() {
            //alert(arguments[0]+arguments[1]+arguments[2]);
           return arguments[0] + arguments[1] + arguments[2];
        }
        function getshowhe() {
            var he = showHe(4, 5, 6);
            alert(he);
        }
    </script>
</head>
<body>
<input type="button" value="click me" onclick="showHe(4,5,7)" />
<input type="button" value="调用showHe函数" onclick="getshowhe()" />
</body>
</html>

原文地址:https://www.cnblogs.com/duanlinlin/p/3010617.html