Now it will be clear why foo() does not work in the following case while bar() does work.
1234567891011
functiontest(){foo();// TypeError "foo is not a function"bar();// "this will run!"varfoo=function(){// function expression assigned to local variable 'foo'alert("this won't run!");}functionbar(){// function declaration, given the name 'bar'alert("this will run!");}}test();