Last active
August 29, 2015 14:27
-
-
Save kulakowka/5629ee7e6b6a56a7ea94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User { | |
constructor(name) { | |
this.name = name; | |
} | |
say(msg) { | |
console.log(this.name + ' say: ' + msg); | |
} | |
} | |
class Admin extends User { | |
constructor(...args) { | |
super(...args); | |
} | |
// расширим метод say() | |
say(...args) { | |
console.log('Attention!!!'); | |
super.say(...args); | |
} | |
} | |
var user = new User('user1'); | |
user.say('hello!'); | |
// user1 say: hello! | |
var admin = new Admin('admin1'); | |
admin.say('welcome!'); | |
// Attention!!! | |
// admin1 say: welcome! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment