DEV Community

Discussion on: Emulating "Private" Variables in JavaScript with Closures and Factory Functions

Collapse
 
somedood profile image
Basti Ortiz

I'm not sure myself, honestly. I'd love to know. When I have the time, I'll try to create a rigorous experiment for this using the DevTools Memory tools.

If I were to make an educated guess, I'd say the difference in memory efficiency would be negligible.

Collapse
 
qm3ster profile image
Mihail Malo

How funny is it, though, that this method is still using closures, the 5 functions capturing privates :D

Thread Thread
 
somedood profile image
Basti Ortiz • Edited

It makes you realize that even though closures are so ubiquitous in JavaScript, not everyone truly understands it.