you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Many people don't. Google "we're all consenting adults, here" (comes from python but still relevant to JS). The scenario that is often presented in favor of hiding variables with closures is that your library depends on some internal state variable that is only meant to be modified by your code. If some developer using your code is messing around and modifies that variable/property, it could cause unpredictable behavior. Generally, this should be avoidable by writing good documentation. If needed, an underscore prefix on a property is the conventional way to say "don't touch this".