Creating Private Variables in JavaScript

preview_player
Показать описание

Because of JavaScripts dependence upon globals, it might be easy to forget that creating private variables can be accomplished quite simply, thanks to closures. In just a few minutes, Ill demonstrate two common techniques which allow for private variables and methods in your projects.
Рекомендации по теме
Комментарии
Автор

Thanks for this! So, how do you create a getter with the second version you showed (via constructor)?

mulicohen
Автор

This doesn't work anymore? Can't get it to do anything.

joeylantis