adapt-security / adapt-authoring

A server-based user interface for authoring eLearning courses using the Adapt framework.
http://adaptlearning.org
10 stars 5 forks source link

Look into neatening up the codebase with new(ish) ES6 features #547

Closed taylortom closed 1 year ago

taylortom commented 1 year ago

Adding class fields in particular would take out a lot of bloat from the init functions to help readability.

TODO: check how doc generator handles this new stuff.

class MyClass {
  myAttr=5
  #myPvtAttr=10
  constructor() {
    this.#myPvtFunc();
  }
  #myPvtFunc() {
    this.#myPvtAttr += 10;
  }
  get p() {
    return this.#myPvtAttr;
  }
}

const c = new MyClass();
console.log(c.p); // 20
console.log(c.#myPvtAttr); // error
c.#myPvtAttr(); // error