Skip to content

Instantly share code, notes, and snippets.

@zehan12
Created October 18, 2024 20:10
Show Gist options
  • Select an option

  • Save zehan12/9a1670a0a4b4443029b2876dbd36bfef to your computer and use it in GitHub Desktop.

Select an option

Save zehan12/9a1670a0a4b4443029b2876dbd36bfef to your computer and use it in GitHub Desktop.
class Notification {
send(message) {
console.log(`Sending notification: ${message}`);
}
}
class EmailNotification extends Notification {
send(message) {
console.log(`Sending email: ${message}`);
}
}
class PushNotification extends Notification {
sendWithToken(message, token) {
console.log(`Sending push notification with token ${token}: ${message}`);
}
}
const email = new EmailNotification();
email.send("Hello!"); // Sending email: Hello!
const push = new PushNotification();
push.sendWithToken("Hello!", "12345"); // Sending push notification with token 12345: Hello!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment