Here is the code
foo() //first function call
function foo(){
console.log("foo 1")
}
var foo=function(){
console.log("foo 2")
}
function foo(){
console.log("foo 3")
}
foo() //second function call
the output for this code is this
foo 3
foo 2
if i comment the first function call then only foo 2
is printed and when i comment the last function call foo 3
is printed i am not understanding how this is happening