4 ms·
Given the topic was Javascript class-based programming in-the-large, I was surprised this paper didn't mention the use of closures as a means to implement encap
by scj 10y ago
Given the topic was Javascript class-based programming in-the-large, I was surprised this paper didn't mention the use of closures as a means to implement encapsulation. Especially during the part about supporting static properties shared between objects. One method to implement something like a static property is to declare a variable (and optional getter/setter) in an anonymous function that also contains the "class" definition.
The most surprising part is the title "... The Good, The Bad, and The Ugly" given that Crockford's similarly named Javascript book brings up relevant cases that I didn't see addressed.