-1

Please help me define what is the use of having the (_) underscores in this piece of script? Are they required/needed and is there a particular purpose for them?

LanSec.prototype._init = function() {
   this._setTransforms();
   this.effect = this.el.getAttribute( 'data-effect' ) || 'effect-1' ;
   this.isAnimating = false;
   this.panels = [].slice.call( this.el.querySelectorAll ('.panel') )
}

After researching I know that it has nothing to do with the underscore library, it's not just a character and that it might mean private. If anyone is familiar with what might be the usage and know that in fact it means private ... please describe what it's for and when to use.

Stephen P
  • 13,259
  • 2
  • 40
  • 61
Elizabeth
  • 271
  • 1
  • 3
  • 7
  • It's just a name for the property, you could just as well name it _"cow"_ or _"__cow"_, for that matter. – Etheryte Feb 18 '15 at 00:09
  • 1
    usually devs use underscore to name "private" methods or properties – Santiago Hernández Feb 18 '15 at 00:10
  • 1
    They are sometimes used to tell other coders that the function is private even though they are only for convension but, used often: http://stackoverflow.com/questions/4484424/underscore-prefix-for-property-and-method-names-in-javascript – jungy Feb 18 '15 at 00:10
  • Sorry for the duplicate guys and thanks for the link to the answered question. Must have used the wrong keyword to search, because I've been searching all day and haven't found the answer. Thanks. – Elizabeth Feb 18 '15 at 00:48

1 Answers1

1

There is no defined special behavior with the underscore character in Javascript. Often, it's used for properties that are meant to be private or reserved for the library that implements them.

Nicholas
  • 2,538
  • 1
  • 17
  • 18