Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #Public #properties #created #Instance #public #fields
ADD COMMENT
Topic
Name
2+4 =