Skip to content

Instantly share code, notes, and snippets.

@rbuckton
Created January 28, 2020 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbuckton/b4dda3f27fba2a055b851bce100a6df5 to your computer and use it in GitHub Desktop.
Save rbuckton/b4dda3f27fba2a055b851bce100a6df5 to your computer and use it in GitHub Desktop.
ECMAScript Strawperson: Concise Method Bodies

Syntax:

// classes
class C {
  #x = 1;
  get x() => this.#x;
  set x(value) => this.#x = value;
  toString() => `C(${this.#x})`;
  static create() => new C();
}

// object literals
const obj = {
  get x() => "hello",
  print() => console.log(`${this.x} world`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment