//閉包實現累加功能 function fn1() { var n = 1; add = function() { n += 1; } function fn2() { n += 1; console.log(n); } return fn2; } var resule = fn1(); resule(); resule();//由于N存在于内存中,所有可以多次调用可以递增 resule(); resule(); resule();