闭包 var globalVal = null; var fn = function () { var a = 1; globalVal = function () { a++; console.log(a); } } fn(); globalVal();//2 globalVal();//3