首页 > 技术文章 > js 闭包演示

Mvloveyouforever 2016-10-28 16:04 原文

function test2()
                {
                    var scope = "global scope";
                    var f = enclose(scope);
                    scope = 'aaa';
                    alert(f());
                }
                
                function enclose(word)
                {
                    function f()
                    {
                        return word;
                    }
                    return f;
                }
                test2();

 

推荐阅读