re: Emulating "Private" Variables in JavaScript with Closures and Factory Functions VIEW POST

re: Has anyone tried something as naive as this? The 101 smoke test worked, it seems like _flees are gonna be garbage collected, what could go wrong?...

Honestly, I doubt that anyone has the time to add this level of complexity just for privacy and encapsulation in JavaScript. I wrote this post to inform people that it is indeed possible, albeit rather impractical. Most of us would just prefer using the _ naming convention to denote member privacy.

I wouldn't say it's a "wrong thing", per se. It's still a cool party trick and all, but if one hopes to use this in production code, they better hope that the next person maintaining their code knows enough about JavaScript to understand why all the boilerplate code is necessary for member privacy.

code of conduct - report abuse