I saw a question today. I was very confused. I never thought of the answer. The question goes like this:
<script>
function g() {
console.log(123)
return true
}
;(function(){
console.log(g) //undefined
console.log(g()) //g is not function
if(g) {
function g() {
console.log(456)
return false
}
}
})()
console.log(g())
</script>
in self-executing functions, using function declarations to define function can also increase variables. Since it has been promoted, why is it still undefind or why is it g is not function?? Please tell the gods one or two, thank you