It looks like it is a problem to hand over a string which has a special meaning.
If really necessary, you evaluate a string.
class Test {
#field = 'foo';
get field() {
return eval('this.' +'#field');
}
}
console.log(new Test().field)
More Related Contents:
- Can I set a private class field using a variable as identifier? How?
- How to use arrow functions (public class fields) as class methods?
- How to avoid bind or inline arrow functions inside render method
- Correct use of arrow functions in React
- Arrow vs classic method in ES6 class
- What is the difference between using constructor vs state = {} to declare state in react component?
- No ways to have class-based objects in javascript?
- What is the difference between class method vs. class field function vs. class field arrow function?
- How do I make a “public static field” in an ES6 class?
- How do I configure ESLint to allow fat arrow class methods
- What are “class fields” in JavaScript?
- Eslint does not allow static class properties
- Declare a class property outside of a class method
- Have a pop up window when clicking on an image
- Accesing 2d arrays from Javascript [closed]
- Send POST data using XMLHttpRequest
- How do you read CSS rule values with JavaScript?
- Migrating AngularJS to Angular 4,5 (with DEMO) [closed]
- How to prevent IFRAME from redirecting top-level window
- Node.js variable declaration and scope
- Multi-dimensional associative arrays in JavaScript
- Pass a string by reference in Javascript
- Best way to serialize/unserialize objects in JavaScript?
- Get list of all input objects using JavaScript, without accessing a form object
- How to alter the headers of a Request?
- Replace multiple characters by one character with regex
- Find and replace specific text characters across a document with JS
- JSON string to JS object
- javascript – match string against the array of regular expressions
- How to access a method from a class from another class?