javascript - Named function cannot be accessed outside the function
过去多啦不再A梦
过去多啦不再A梦 2017-06-12 09:30:01
0
1
653
var func2 = function func1() {
        console.log(1010)
        // console.log('func1', func1)
    }

    function func3 () {
        console.log(1010)
    }

    func3() // 1010
    func2() // 1010
    func1() // func1 is not defined

func1 cannot be accessed, please explain, please explain

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
学习ing

The function you create is created through function expression, not through function declaration statement, function name can only be used in this function expression. Notefunction declaration statements and Function expressionsThe way to define functions is different.

Refer to the Javascript Definitive Guide 8.1 Function Definition section:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template