class and methods
/* CLASS */
class User {
}
/* FUNCTIONS / METHOD */
register () {
console.log('User Registered...');
}
/* CLASS AND METHOD EXAMPLES */
class User {
constructor(username, email, password) {
this.username = username;
this.email = email;
this.password = password;
}
static countUsers() {
console.log('There are 50 users');
}
register() {
console.log(this.username + ' is Registered')
}
}
let John = new User('John', 'John@hotmail.com', '1234'); // Creating new user John
John.register(); // Calling register method
User.countUsers(); // Calling countUsers method
John.register(); // calling method register