Created
November 26, 2017 15:42
-
-
Save nikkaroraa/2d59fef7b2cb33fcad6f045789ab6060 to your computer and use it in GitHub Desktop.
this keyword
This file contains hidden or 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 globalFunction() { | |
| console.log(this); | |
| } | |
| globalFunction(); //[object Window] | |
| //globalFunction() is equivalent to window.globalFunction() | |
| var myObj = {name: "obj"}; | |
| myObj.logThis = function () { | |
| console.log(this); | |
| } | |
| myObj.logThis(); //[object myObj] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment