Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 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.nome = 'Mario';
  42.  
  43. this.printmyname = function () {
  44. console.log(_this2.nome);
  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.  
  60. gender = 'male';
  61.  
  62. printGender = () => {
  63. console.log(this.gender);
  64. }
  65. }
  66. class Person extends Human{
  67.  
  68.  
  69. nome = 'Mario';
  70.  
  71.  
  72. printmyname = () =>{
  73. console.log(this.nome);
  74. }
  75. }
  76. const person = new Person();
  77. person.printmyname();
  78. person.printGender();</script></body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement