Can a public field be defined in an ES6 class as shown below:
class Device {
public id=null;
public name=null;
constructor(id,name,token) {
this.id = id; // I want this field to be public
this.name = id; // I want this field to be public
this.token = token; // this will be private
}
}
I understand that it is simple to have private fields by placing them in the constructor (like the 'token' field in the example code above), but how can we define public fields?