Advertisement
lemansky

Untitled

Apr 6th, 2021
1,457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class User {
  2.     constructor(name, email) {
  3.         this.name = name;
  4.         this.email = email;
  5.     }
  6.  
  7.     login(date){
  8.         this.date = date;
  9.         console.log(`${this.email} logged on ${this.date}`);
  10.     }
  11. }
  12.  
  13. class Admin extends User {
  14.     constructor(name, email, rank){
  15.         super(name, email);
  16.         this.rank = rank;
  17.     }
  18.     givePrivilige(privilage){
  19.         console.log(`${this.email} has privilige ${privilage}`);
  20.     }
  21.    
  22. }
  23.  
  24. const user = new User("john", "john@gmail.com");
  25. user.login("2020-12-01");
  26.  
  27. const admin = new Admin("jane", "jane@gmail.com", "site-admin");
  28. admin.login("2020-12-01");
  29. admin.givePrivilige("deleteUsers");
  30. console.log(admin);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement