クラスのプロパティをインスタンス化せずにリストする方法を教えてください。クラスのプロパティをインスタンス化せずに列挙する
例:の
class User {
constructor({ id_user, first_name }) {
this.props = {
id_user,
first_name
}
}
}
// Obviously won't work but you get the point
console.log(User.props) // should log id_user, first_name
できません。これらのプロパティは、 'constructor'が呼び出されるまで構築されません。 –
奇妙な - 少なくとも彼らの名前を取得する方法があると思っていたでしょう –
静的で関数として宣言する必要があります –