Guest User

Untitled

a guest
May 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 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. 'use strict';
  12.  
  13. var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
  14.  
  15. function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  16.  
  17. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
  18.  
  19. var Human = function Human() {
  20. var _this = this;
  21.  
  22. _classCallCheck(this, Human);
  23.  
  24. this.gender = 'male';
  25.  
  26. this.printGender = function () {
  27. console.log(_this.gender);
  28. };
  29. };
  30.  
  31. var Person = (function (_Human) {
  32. _inherits(Person, _Human);
  33.  
  34. function Person() {
  35. var _this2 = this;
  36.  
  37. _classCallCheck(this, Person);
  38.  
  39. _get(Object.getPrototypeOf(Person.prototype), 'constructor', this).apply(this, arguments);
  40.  
  41. this.name = 'Brix';
  42.  
  43. this.printMyName = function () {
  44. console.log(_this2.name);
  45. };
  46. }
  47.  
  48. return Person;
  49. })(Human);
  50.  
  51. var person = new Person();
  52. person.printMyName();
  53. person.printGender();
  54. </script>
  55.  
  56.  
  57.  
  58. <script id="jsbin-source-javascript" type="text/javascript">class Human {
  59. gender = 'male';
  60.  
  61. printGender = () => {
  62. console.log(this.gender);
  63. }
  64. }
  65.  
  66. class Person extends Human {
  67. name = 'Brix';
  68.  
  69.  
  70. printMyName = () => {
  71. console.log(this.name);
  72. }
  73. }
  74.  
  75. const person = new Person();
  76. person.printMyName();
  77. person.printGender();</script></body>
  78. </html>
Add Comment
Please, Sign In to add comment