js 覆盖和重载 函数

//测试同名方法 
    function testFun() { 
        showResult('this is a function named \'testFun\' with no arguments.'); 
    }; 
    function testFun(arg) { 
        showResult('this is a function named \'testFun\' with one argument,the argument is '+arg); 
    }; 

testFun();
testFun("jQuery");

结论:方法重名,JS会以最后定义的函数作为函数体。当然这不包括JS中的继承中的覆盖。 

猜你喜欢

转载自qiaolevip.iteye.com/blog/2026127
今日推荐