The other answers here work, but are not good. Referencing the class name from within the class is something you shouldn't do. What if the class name changes? what if you are working with inheritance? It will be broken. use this.constructor to get to the the static methods on a given instance
class User {
constructor(fields) {
this.email = fields.email;
this.name = fields.name;
}
static async exist(email) {
return setTimeout(function() {
return userEmails.includes(email)
}, 2000)
}
async storeEmail() {
let userExist = await this.constructor.exist(this.email)
if (userExist) {
console.log('User exist')
} else {
users.push(this.email)
console.log(userEmails)
}
}
};