Open lmislm opened 9 months ago
为什么形成了闭包,如何销毁
const api = async () => { let count = 0; return async () => { count++; return { count }; }; }; const test = async () => { const fn = await api(); return async () => { const res = await fn(); console.log(res, "===="); }; }; async function test1() { const fn = await test(); fn(); fn(); fn(); fn(); } test1();
为什么形成了闭包,如何销毁