Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var person1 = {
- firstname: 'Jane',
- lastname: 'Doe',
- getFullName: function() {
- var fullname = this.firstname + ' ' + this.lastname;
- return fullname;
- }
- }
- // function borrowing
- var person2 = {
- firstname: 'John',
- lastname: 'Doe'
- }
- person1.getFullName.apply(person2); // => John Doe
- // Here we are invoking person1's getFullName method but calling it on person2
- // Thus we are borrowing person1's function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement