Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. var person1 = {
  2. firstname: 'Jane',
  3. lastname: 'Doe',
  4. getFullName: function() {
  5.  
  6. var fullname = this.firstname + ' ' + this.lastname;
  7. return fullname;
  8.  
  9. }
  10. }
  11.  
  12. // function borrowing
  13. var person2 = {
  14. firstname: 'John',
  15. lastname: 'Doe'
  16. }
  17.  
  18. person1.getFullName.apply(person2); // => John Doe
  19. // Here we are invoking person1's getFullName method but calling it on person2
  20. // Thus we are borrowing person1's function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement