News for hackers. Stuff that matters.
Re:Public and private class fields by fsnarskiy on Thursday December 13, 2018 @08:37PM (#18677716)
Also to clarify something, it technically wouldn't be a closure since -

A closure is an inner scope that has a references to its outer scope.

It happens any time a function is created (technically, even global). That actually even goes for “IIF(Instantly Invoked Functions)”, since the function is created first (has references to its outer scope) and THEN is called (two separate “events” in js). The call is not part of the function decl/expr and therefore comes next. Between the two there’s a gap and that’s where you’d say there’s a closure. After that call the reference to the function ceases to exist and the garbage collection tears down the function and with that the closure too.

There are no comments on this comment yet.