function foo(){

// code

}


上面这段函数声明如果放到if else语句中,有些浏览器会报错

if(){functionfoo(){//code}foo();}


但是可以写成下面这样:

if(){varfoo=function(){//code}foo();}