Search code examples
javascriptnode.jsnaming-conventions

Double underscore vs single underscore in nodeJS


I have encountered 2 conflicting naming conventions while using nodeJS. Some variables start with a single underscore, like _temp, while some start with double underscore, like __dirname.

I have been trying to search for an answer to this naming convention difference. I checked out Double Underscore in front of a variable but the answer was very specific to __dirname and __filename. It didn't address the conflicting naming convention.

It will be great if someone could provide me with a resource for this.


Solution

  • I can be wrong, but as far as I know, there is only one convention in js: "if method or variable supposed to be private, use underscore in front of it - _privateMethod". And even this one is kind of "unofficial". Double underscore is not a naming convention. Just some developer from node decided to name thing like this.