-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
33 lines (26 loc) · 752 Bytes
/
Copy pathprototype.js
File metadata and controls
33 lines (26 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function User(email, name){
this.email = email;
this.name = name;
this.online = false;
}
User.prototype.login = function(){
this.online = true;
console.log(this.email, 'has logged in');
};
User.prototype.logout = function(){
this.online = false;
console.log(this.email, 'has logged out');
};
function Admin(...args){
User.apply(this, args);
}
Admin.prototype = Object.create(User.prototype);
Admin.prototype.deleteUser = function(u){
users = users.filter(user => {
return user.email != u.email;
});
};
var userOne = new User('ryu@ninjas.com', 'Ryu');
var userTwo = new User('yoshi@mariokorp.com', 'Yoshi');
var admin = new Admin('shaun@ninjas.com', 'Shaun');
var users = [userOne, userTwo, admin];