Search
 
SCRIPT & CODE EXAMPLE
 

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');
Comment

Public properties can be created via Static public fields

// ES2022

const computedFieldKey = Symbol('computedFieldKey');
class StaticPublicFieldClass {
  static identifierFieldKey = 1;
  static 'quoted field key' = 2;
  static [computedFieldKey] = 3;
}
console.log(StaticPublicFieldClass.identifierFieldKey) //output -> 1
console.log(StaticPublicFieldClass['quoted field key']) //output -> 2
console.log(StaticPublicFieldClass[computedFieldKey]) //output -> 3
Comment

PREVIOUS NEXT
Code Example
Javascript :: Private slots are new and can be created via Static initialisation blocks in classes 
Javascript :: see wss request on network tab 
Javascript :: strapi extend user model 
Javascript :: cache blogposts for 24 hours react native 
Javascript :: pass data from popup js 
Javascript :: upload image to server react next 
Javascript :: typeorm sqlite Using Entity Manager 
Javascript :: typeorm caching queries time limit by id 
Javascript :: on change jquery kendo switch 
Javascript :: threejs check if camera is pointing towards object 
Javascript :: promtail +verbose 
Javascript :: add and remove multiple markers on google maps js 
Javascript :: react native update performance useReducer 
Javascript :: getData(x, y, callback) and showData() callback function 
Javascript :: Adding Notices in the Block Editor Wordpress 
Javascript :: hide modal event listener js 
Javascript :: how to send Flutter Color as json || convert String to Color Flutter 
Javascript :: javascript python like for loop 
Javascript :: react native red Triangle Down 
Javascript :: javascrpt 
Javascript :: respons compression 
Javascript :: change candle color react highcharts 
Javascript :: node fs stream pipe promise 
Javascript :: react call component state 
Javascript :: angular view not changing on model 
Javascript :: discord.js anonymous channel 
Javascript :: lieke==1 
Javascript :: get members of a group graph pnp js 
Javascript :: chrome extension sendmessage await until getdata 
Javascript :: random height fallling object in js 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =