重载:根据传入的参数不一样,动态决定调用哪一种方法
    原因:js不支持重载,重复声明,就被覆盖掉了
    可以使用arguments对象模拟重载 通过下标去读

    1. <script>
    2. function go(a,b){
    3. console.log(a+b)
    4. }
    5. function go(a){
    6. console.log(a);
    7. }
    8. function show(){
    9. if(arguments.length==2){
    10. console.log(arguments[0]+arguments[1])
    11. }else if(arguments.length==1){
    12. console.log(arguments[0])
    13. }
    14. }
    15. show(20) //20
    16. show(20,30) //50 */
    17. /*eg:
    18. var a=20;
    19. var a=30; //此时a的值为30 */
    20. </script>