js-js的不重载

* 什么是重载?方法名相同,参数列表不同
  - Java里面有重载
* js里面不存在重载!

<html>
    <head>
        <title>World</title>
        <style type="text/css">
        </style>
    </head>
    <body>
        <script type="text/javascript">

            function add(a, b) {
                return a+b;
            }

            function add(a, b, c) {
                return a+b+c;
            }

            function add(a, b, c, d) {
                return a+b+c+d;
            }

            alert(add(1,2));    //NaN
            alert(add(1,2,3));    //NaN
            alert(add(1,2,3,4));//10
            
        </script>
    </body>
</html>

  由此可以知道JS的不重载!

原文地址:https://www.cnblogs.com/ibabyli/p/9889453.html