Created
November 27, 2018 10:12
-
-
Save ragmha/7e169d919e73d839b994f225b5e098a5 to your computer and use it in GitHub Desktop.
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 | |
function myFunction() { | |
console.log("Function::", this); | |
} | |
myFunction(); // => Window is invoking the function | |
// Lamda | |
const myanotherFunc = () => console.log("Lamda::", this); | |
myanotherFunc(); | |
// Object literal | |
const myObj = { | |
myMethod() { | |
console.log("Object::", this); | |
}, | |
}; | |
myObj.myMethod(); // => myObj is invoiking the function | |
// Classes | |
class MyClass { | |
myMethod() { | |
console.log("Class::", this); | |
} | |
} | |
const myInstance = new MyClass(); | |
myInstance.myMethod(); // => myInstance is invoking the function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment