On the problem that the output of self-executing function definition function declaration result is undefined

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

Mar.28,2021
The

function is block-level in newer browsers. Some


you can use the old version of ie to execute this code. Take a look at the results


Block level scope

I suggest you take a look at this, which talks about this issue in detail, which is related to the compatibility of browser implementation and historical legacy

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb4d46-482df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb4d46-482df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?