作用域

140 阅读1分钟
    作用域 : 全局作用域  私有作用域 块级作用域
    作用域都是栈内存,提供代码运行环境的;
    var total=0;
    function fn() {
        function f() {
            // 函数f的上一级作用域是fn形成的私有作用域
            console.log(total);
            var total=100;
        }
        var total= 1;
        f();
    }
    fn();