0

I have just come across some code of this form:

class Foo {
  someValue = 1;
}

This does seem to work natively in the browser, and behaves as if it was:

class Foo {
  constructor() {
    this.someValue = 1;
  }
}

But I can't see this form documented at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes - or perhaps I'm missing something.

Is it exactly equivalent to the constructor version? What standard is it part of?

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219

0 Answers0