Guest User

Untitled

a guest
Jan 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. const FANCY_TOILET = new FancyToilet('Kohler');
  2.  
  3. function Toilet(brand) {
  4. this.brand = brand;
  5. this.tankCapacity = 4.8;
  6. }
  7.  
  8. Toilet.prototype.sanitize = function() {
  9. console.log(`Sanititizing ${this.brand}`);
  10. }
  11.  
  12. function FancyToilet(brand) {
  13. Toilet.call(this, brand);
  14. // this.constructor = FancyToilet;
  15. }
  16.  
  17. FancyToilet.prototype = new Toilet();
  18.  
  19. FancyToilet.prototype.useBidet = function() {
  20. console.log('Ahh, refreshing!');
  21. }
  22.  
  23. console.log(FANCY_TOILET.constructor);
  24. FANCY_TOILET.useBidet(); // 'Uncaught TypeError: FANCY_TOILET.useBidet is not a function'
  25.  
  26. FANCY_TOILET.sanitize();
  27.  
  28. console.log(FANCY_TOILET.brand);
Add Comment
Please, Sign In to add comment