Friday, December 7, 2018

the leading underscore as a JavaScript naming convention

Alright in C# this would typically be used for a class-wide private variable that is otherwise in camel case and is different from other private variables in camel case by way of its class-wide in availability. Fine. In JavaScript there is no public and private and encapsulation is trickier. The leading underscore (with an otherwise camel case name) is used for "public" methods which are really intended to be "private" and which an outside user (maybe using a third party library perhaps) should be wary of just grabbing ahold of and interacting with.

No comments:

Post a Comment