Answers for "Public properties can be created via Instance public fields"

0

Public properties can be created via Instance public fields

// ES2022

class InstPublicClass {
  // Instance public field
  instancePublicField = 0; // (A)

  constructor(value) {
    // We don’t need to mention .property elsewhere!
    this.property = value; // (B)
  }
}

const inst = new InstPublicClass('constrArg');
Posted by: Guest on March-25-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language