Advertisement
lemansky

Untitled

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