js作用域

遨翔在知識的海洋裡發表於2018-04-27
        var url;
        url = "aa";

        test1()
        function test1() {
            console.log(url)  //aa
        }
        
        console.log(url)  //aa
複製程式碼
        var url;
        test1()

        function test1() {
            url = "aa";
            console.log(url)  //aa
        }

        console.log(url) //aa
複製程式碼
        var url;
        url = "bb";
        test1()

        function test1() {
            url = "aa";
            console.log(url)  //aa
        }

        console.log(url)  //aa
複製程式碼
        var url;
        test1()

        function test1() {
            url = "aa";
            console.log(url)  //aa
        }

        console.log(url) //aa
複製程式碼

相關文章