JS 4 OOP Pillars

Run Settings
LanguageJavaScript
Language Version
Run Command
//Encapsulation //Inheritance class Mail { constructor(author) { this.from = author; this._contacts = []; } sendMessage(msg, to) { console.log(`you send: ${msg} to ${to} from ${this.from}`); this._contacts.push(to); } showAllContacts() { return this._contacts; } } class WhatsApp extends Mail { constructor(author) { super(author); this.username = 'dicoding'; this.isBussinessAccount = true; } myProfile() { return `my name ${this.username}, is ${this.isBussinessAccount ? 'Business' : 'Personal'}`; } } const wa1 = new WhatsApp('080111000222'); console.log(wa1.myProfile());
Editor Settings
Theme
Key bindings
Full width
Lines