Created
January 13, 2017 18:33
-
-
Save optimistanoop/9bd3cc59459fb9b80a18653ae19c4a39 to your computer and use it in GitHub Desktop.
this in Js
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
// This is like a parameter to a function and it depends on the value binded to it. | |
// Binding of value to 'this' is comptely taken care by language. | |
// The calling object of the function is binded to "this". | |
var obj = { | |
method: function (){ | |
console.log(this); | |
}, | |
param:'value' | |
}; | |
obj.method(); | |
// here the method logs obj . | |
//hence calling object of the function reffered to this inside function. | |
// so, key here for 'this' is '.' , to the left of which obj is binded to "this" in case of calling the method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment