Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. var Person = function(name) {
  2. this.name = name;
  3. };
  4.  
  5. // Part 2
  6. Person.prototype.getName = function() {
  7. return this.name;
  8. };
  9.  
  10. var thomas = new Person('Thomas');
  11. var amy = new Person('Amy');
  12.  
  13. console.info(thomas.name) // --> "Thomas"
  14.  
  15. // Part 3
  16.  
  17. console.info(thomas.getName.call(amy)); // Amy
  18.  
  19. // Part 4
  20.  
  21. delete Person.prototype.getName;
  22. console.info(thomas.getName); // undefined
  23. console.info(amy.getName); // undefined
Add Comment
Please, Sign In to add comment