Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //Sub Classes, ES6 Inheritance and extending classes
  2.  
  3. class Person {
  4. constructor(firstName, lastName){
  5. this.firstName = firstName;
  6. this.lastName = lastName;
  7. }
  8.  
  9. greeting(){
  10. return `Hello there ${this.firstName} ${this.lastName}`
  11. }
  12. }
  13.  
  14. class Customer extends Person {
  15. constructor(firstName, lastName, phone, membership){
  16. super(firstName, lastName);
  17.  
  18. this.phone = phone;
  19. this.membership = membership;
  20. }
  21. static getMembershipCost(){
  22. return 500;
  23. }
  24. }
  25.  
  26. const john = new Customer('John', 'Doe', '555-555-5555', 'Standard');
  27.  
  28. console.log(john);
  29. console.log(john.greeting());
  30. console.log(Customer.getMembershipCost());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement