one question.
why did you write the last example as
class Computer {
constructor() {
this[Symbol.toStringTag] = "Computer";
}
}
and not like
class Computer {
[Symbol.toStringTag] = "Computer";
}
Developer: javascript, typescript, React, ... I love to discover new things, exploring code of libraries and understand how things work.
Fan of creative hobbies :)
I write like this because if I'm not mistaken the public class field will be available in ES2022.
Or we currently can use it thanks to babel plugin @babel/plugin-proposal-class-properties
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
one question.
why did you write the last example as
class Computer {
constructor() {
this[Symbol.toStringTag] = "Computer";
}
}
and not like
class Computer {
[Symbol.toStringTag] = "Computer";
}
I write like this because if I'm not mistaken the
public class field
will be available in ES2022.Or we currently can use it thanks to babel plugin
@babel/plugin-proposal-class-properties