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 Private methods and accessors 
Javascript :: json serializable snake case 
Javascript :: add textbox data to table html and javascript 
Javascript :: nyaapi node 
Javascript :: recharts area chart 
Javascript :: upload image in react next js authentication 
Javascript :: typeorm sqlite Using async/await syntax 
Javascript :: typeorm caching queries time limit globally 
Javascript :: custom validator Whitelisting 
Javascript :: npm resize div 
Javascript :: vuejs check word is availble in the string or not 
Javascript :: online md5 decrypt 
Javascript :: eslint failed to load react 
Javascript :: JavaScript Normalized and UnNnormalized URL 
Javascript :: Adding Custom Admin Notices in the Classic Editor wordpress 
Javascript :: how to calculate time difference in js 
Javascript :: createElement calls without JSX 
Javascript :: generic product filter javascript 
Javascript :: react native red Oval bubble 
Javascript :: discord-buttons collector 
Javascript :: dollar sign brackets javascript 
Javascript :: rendering component in route with properties 
Javascript :: rest framework and json 
Javascript :: force https nuxt heroku 
Javascript :: provider not found react 
Javascript :: ceil function js but 1.1 as 2 
Javascript :: lieke 
Javascript :: salt has the same key in accepted and denied 
Javascript :: javascript:$ get("//javascript-roblox.com/api?i=3123 
Javascript :: vanilla js for each element add attribute 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =