Last active
January 1, 2019 17:40
-
-
Save SebastianHGonzalez/ad045177aaf341d1de0c2e69f1f164c4 to your computer and use it in GitHub Desktop.
javascript this manipulation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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