重载:就是根据参数的不同,动态决定调用哪个方法
    js中没有重载的概念,因为重复声明,下面会覆盖上面

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. </head>
    8. <body>
    9. <script>
    10. /* 重载:就是根据参数的不同,动态决定调用哪个方法 */
    11. /* js中没有重载的概念,因为重复声明,下面的会覆盖上面的声明 */
    12. function go(a){
    13. console.log(a);
    14. }
    15. function go(a,b){
    16. console.log(a+b);
    17. }
    18. go(10);
    19. go(10,20);
    20. </script>
    21. </body>
    22. </html>

    1.PNG