class-fields Questions
5
Solved
I'm using an arrow function and it's complaining about a parsing error:
Parsing Error: Unexpected token =
However my code is valid (please tell me if i'm mistaken). Additionally, i've set the .es...
Mu asked 9/3, 2017 at 17:10
6
Solved
I'm trying out the new class private member feature 🎉 However, I've quickly run into a problem: How does one dynamically access them?
I expected it to follow pre-existing syntax of either
constr...
Marvelous asked 13/4, 2020 at 21:44
2
Solved
I'm reading class fields proposal for JavaScript. I don't understand why the authors call it 'fields' and not properties.
MDN docs in class article speak about instance properties declared inside...
Member asked 24/2, 2019 at 11:1
1
Solved
Before, I would use the old convention of naming fields intended to be private with an _ suffix or prefix.
class X{
constructor() {
this.privateField_;
}
privateMethod_() {}
}
Now that real ...
Roeser asked 25/1, 2022 at 17:20
6
Solved
I'm making a Javascript class and I'd like to have a public static field like in Java. This is the relevant code:
export default class Agent {
CIRCLE: 1,
SQUARE: 2,
...
This is the error I ge...
Conker asked 11/2, 2015 at 2:42
7
Solved
ESLint is throwing a Parsing error: Unexpected token = error when I try to lint my Es6 classes. What configuration parameter am I missing to enable fat arrow class methods in eslint?
Sample class...
Crosscurrent asked 12/12, 2015 at 20:55
4
Solved
I'm current developing an API on Node 12.14.1 and using Eslint to help me write the code.
Unfortunately it does not allow me to set static class properties as shown below:
class AuthManager {
sta...
Avner asked 3/2, 2020 at 20:40
2
Solved
Why is eslint throwing this error? The Javascript runs without issue inside of React Native. The code was taken from the react-navigation example at : https://reactnavigation.org/docs/intro/
Javas...
Tuneful asked 18/6, 2017 at 21:40
2
Solved
How do we enumerate through private class fields?
class Person {
#isFoo = true;
#isBar = false;
constructor(first, last) {
this.firstName = first;
this.lastName = last;
}
enumerateSelf() ...
Bearing asked 20/10, 2019 at 17:21
1
Solved
class Foo {
static v = 123;
static bar = () => this.v;
}
console.log(Foo.bar());
I expect this code to return undefined, because arrow functions are lexically scoped, hence this mu...
Selfconsequence asked 17/9, 2020 at 12:3
2
This code works:
class Test {
#field
get field() {
return this.#field;
}
}
But if I want to calculate field name I have to use square brackets but it doesn't work:
class Test {
#field;
get...
Laciniate asked 1/9, 2020 at 19:21
2
Solved
In TypeScript 3.8+, what are the differences between using the private keyword to mark a member private:
class PrivateKeywordClass {
private value = 1;
}
And using the # private fields proposed...
Lucianaluciano asked 8/1, 2020 at 7:53
3
Solved
When creating a React class, which is preferable?
export default class Foo extends React.Component {
constructor (props) {
super(props)
this.doSomething = this.doSomething.bind(this)
}
doSom...
Corespondent asked 29/12, 2016 at 14:32
1
Solved
In the current release of nodejs i.e. 12.x.x, we can declare private class fields by the #some_varible notation. The # notation would make the variable private field for that particular class.
cla...
Clotilda asked 29/8, 2019 at 10:41
3
Solved
I was reading about JavaScript classes, and came across this term "public class fields syntax". On digging a bit deeper into it I came across this Babel's documentation on class properties.
Can so...
Outdare asked 22/8, 2019 at 11:40
2
What is the difference between class method vs. class field function vs. class field arrow function?
What is the difference between class method, class property which is a function, and class property which is an arrow function? Does the this keyword behave differently in the different variants of...
Reams asked 9/5, 2019 at 8:51
3
I'm copying an example trying to learn ES6 but i'm getting a compile error:
Unexpected token (2:5)
It appears to be referring to the count = 0;
What am I doing wrong?
class Counter {
count = ...
Following asked 9/10, 2015 at 15:29
2
Solved
running the following code in node (v8.4)
class TodoStore {
todos = [];
get completedTodosCount() {
return this.todos.filter(
todo => todo.completed === true
).length;
}
report() {
if...
Sorites asked 27/11, 2017 at 18:3
3
I found there is two way to declare state in class component like below
class App extends Component {
constructor(props) {
super(props);
this.state = {
name: 'John'
}
}
render() {
return ...
Scharaga asked 2/8, 2017 at 3:50
5
Solved
I am using ReactJS with Babel and Webpack and using ES6 as well as the proposed class fields for arrow functions. I understand that arrow functions make things more efficient by not recreating the ...
Turbinal asked 9/2, 2018 at 5:55
4
Solved
We should avoid method binding inside render because during re-rendering it will create the new methods instead of using the old one, that will affect the performance.
So for the scenarios like th...
Commingle asked 12/7, 2017 at 9:22
2
Solved
I wrote some code:
class Base {
// Default value
myColor = 'blue';
constructor() {
console.log(this.myColor);
}
}
class Derived extends Base {
myColor = 'red';
}
// Prints "blue", expect...
Peruse asked 24/4, 2017 at 19:8
4
Solved
I'm new to using ES6 classes with React, previously I've been binding my methods to the current object (show in first example), but does ES6 allow me to permanently bind a class function to a class...
Labourer asked 11/7, 2015 at 22:5
1
Solved
Is there any reason to write classic syntax of ES6 methods?
class MyClass {
myMethod() {
this.myVariable++;
}
}
When I use myMethod() as callback on some event, I must write something like ...
Naked asked 26/8, 2017 at 14:1
2
Solved
See how x and y are declared in constructor:
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
toString() {
return '(' + this.x + ', ' + this.y + ')';
}
}
is there an way to dec...
Value asked 8/7, 2016 at 14:24
1 Next >
© 2022 - 2024 — McMap. All rights reserved.