Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. class Human {
  12. constructor() {
  13. this.city = 'Sunnyvale';
  14. }
  15.  
  16. printCity() {
  17. console.log(this.city);
  18. }
  19. }
  20.  
  21.  
  22. class Person extends Human {
  23. constructor() {
  24. super();
  25. this.name = 'Dev';
  26. this.age = 30;
  27. }
  28.  
  29. printMyInfo() {
  30. console.log(this.name);
  31. console.log(this.age);
  32. }
  33. }
  34.  
  35. const person = new Person();
  36. person.printMyInfo();
  37. person.printCity();
  38. </script>
  39.  
  40.  
  41.  
  42. <script id="jsbin-source-javascript" type="text/javascript">class Human {
  43. constructor() {
  44. this.city = 'Sunnyvale';
  45. }
  46.  
  47. printCity() {
  48. console.log(this.city);
  49. }
  50. }
  51.  
  52.  
  53. class Person extends Human {
  54. constructor() {
  55. super();
  56. this.name = 'Dev';
  57. this.age = 30;
  58. }
  59.  
  60. printMyInfo() {
  61. console.log(this.name);
  62. console.log(this.age);
  63. }
  64. }
  65.  
  66. const person = new Person();
  67. person.printMyInfo();
  68. person.printCity();</script></body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement