I have the following code:
class Base {
constructor() {
console.log(this.table)
}
static getAll() {
console.log("select * from " + this.table);
}
}
class User extends Base {
static table = 'user'
}
class Room extends Base {
static table = 'room'
}
let user = new User()
let room = new Room()
User.getAll()
Room.getAll()
output:
undefined
undefined
select * from user
select * from room
the method getAll works and returns "Select * from User" but, the same field is not accessible, at least I could not on the constructor.
how can I access this static field? thank you