Skip to content

Instantly share code, notes, and snippets.

@SebastianHGonzalez
Last active January 1, 2019 17:40
Show Gist options
  • Save SebastianHGonzalez/ad045177aaf341d1de0c2e69f1f164c4 to your computer and use it in GitHub Desktop.
Save SebastianHGonzalez/ad045177aaf341d1de0c2e69f1f164c4 to your computer and use it in GitHub Desktop.
javascript this manipulation example
function greet() {
return "Hello " + this.name ;
}
const john = {
name: "John"
}
const jane = {
name: "Jane"
}
greet.apply(jhon);
// <- "Hello Jhon"
jane.greet = greet;
jane.greet();
// <- "Hello Jane"
greet();
// <- "Hello "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment