back

by porridgeraisin·1y ago·view on hn ↗
> Does JS provide static variables

  const f = (() => {
      let cnt = 0;
      return () => console.log("cnt", cnt);
  })();
:-)
2 comments
Yep, like I said if it doesn't have it then you have to lift the variable to another scope:

> If not, then that forces you to lift it to ... the surrounding function

That abbreviation of count is an interesting choice. ;-)