Skip to content

Instantly share code, notes, and snippets.

@ellereeeee
Created January 16, 2018 08:24
Show Gist options
  • Save ellereeeee/18db5581c12ed804bff703cbda103607 to your computer and use it in GitHub Desktop.
Save ellereeeee/18db5581c12ed804bff703cbda103607 to your computer and use it in GitHub Desktop.
name = "GLOBAL OBJECT NAME";
function greet (name) {
return `Hi ${name}, my name is ${this.name}!`
}
var bob = {
name: 'Bob',
greet: greet
}
bob.greet('Jane'); // Hi Jane, my name is Bob!
var greetFn = bob.greet; // this binding is lost!
greetFn('Jane'); // // Hi Bob, my name is GLOBAL OBJECT NAME!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment