For example, I noticed that in the jQuery UI widget factory, methods like _init
, _start
, _on
, ect.
5
The most common use for a leading underscore in my experience is to identify an object member (field/function) that is not supposed to be used by regular users. This means the member is regarded as “private”. Because JavaScript doesn’t enforce visibility modifiers (everything’s considered “public”), it’s common to use coding conventions like this to indicate visibility. As a commenter stated, members with a leading underscore are considered more specifically to have “internal” scope. They can be freely accessed within the library, or by those writing extensions to it, but should not be accessed by users of the library.
1