1 function f1() { 2 alert('first f1'); 3 } 4 5 function f1(name) { 6 alert(name); 7 } 8 9 // f1(); //此处调用f1()方法输出结果是什么?为什么? 10 // //在js中,方法定义的时候,如果方法名字相同,那么会以最后一个定义的为准(会覆盖所有前面的定义),所以此时,调用f1()其实是调用的第二个定义,但是又没有传递参数,所以没有为name赋值,变量没有赋值就是undefined.