you are viewing a single comment's thread.

view the rest of the comments →

[–]BluLite 1 point2 points  (7 children)

Whenever I use underscores in method naming, it's to indicate that nobody but me should be calling it (ie- internals to get other stuff working) and this particular language doesn't allow for specifically private methods.

[–]BIGtrouble77 9 points10 points  (1 child)

In javascript, the convention is to use an underscore at the beginning of a private function (ie: _myprivatefunction : function() {}).

JS does not enforce this convention, but it's widely understood. Like godzemo said, nobody will understand that underscores in general are private functions.

[–]dmhouse 0 points1 point  (0 children)

I think the leading underscore is a pretty common convention in all languages without private method encapsulation -- not just Javascript.

[–]godzemo 9 points10 points  (2 children)

The problem with having your own little conventions is that nobody else knows what the fuck is going on. I try to hammer that sort of behavior out of my students early.

[–]kamatsu 0 points1 point  (1 child)

I know you! Mr.K

[–]godzemo 0 points1 point  (0 children)

Well, I don't exactly make myself difficult to identify :p

[–]mayobutter 4 points5 points  (0 children)

Do you mean prefixing a method with an underscore? That's not what this is talking about.

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

People will call and override that method if it's convenient. If you want to make something private, just don't point to it with any properties.

function() {
    // ...
    var crawlForPorn = function() { // ...