Hyper Open Edge Cloud

Guideline Private Method Starts With Underscore

Consistent patterns.
  • Last Update:2017-04-05
  • Version:001
  • Language:en

Private Method Starts With Underscore

Private methods should use a leading underscore to separate them from public methods (although this does not technically make a method private).

Good Example:

var person = {
  "getName": function () {
    return this._getFirst() + " " + this._getLast();
  },
  "_getFirst": function () {
    // ...
  },
  "_getLast": function () {
    // ...
  }
};

Bad Example:

var person = {
  "getName": function () {
    return this.getFirst() + " " + this.getLast();
  },
  // private function
  "getFirst": function () {
    // ...
  }
};