Well, well, well...
What a great title to some not so simple topic. Imagine that you were asked to build a Javascript class that is called Account, and this class is used to model an employee's bank account. As expected we are going to add some data members to it so that we can access and store values in them once we make instances of this class. Once we for example store functions as values to some of these member variables(object keys),we are going to define these functions outside the class and sometimes we may try to access the values of the object itself.
Which object exactly?
Well, it depends on which object you are using to access so we use the keyword 'this' to refer to the current object that we are using.
What about that?
I'm not sure if it was a real thing in programming but If I could say from my understanding then I'm going to say that it is just a word to describe any other object not related to the current object we reference using the 'this' keyword.
Hope 'that' helped clear some aspects of 'this' :P
What a great title to some not so simple topic. Imagine that you were asked to build a Javascript class that is called Account, and this class is used to model an employee's bank account. As expected we are going to add some data members to it so that we can access and store values in them once we make instances of this class. Once we for example store functions as values to some of these member variables(object keys),we are going to define these functions outside the class and sometimes we may try to access the values of the object itself.
Which object exactly?
Well, it depends on which object you are using to access so we use the keyword 'this' to refer to the current object that we are using.
What about that?
I'm not sure if it was a real thing in programming but If I could say from my understanding then I'm going to say that it is just a word to describe any other object not related to the current object we reference using the 'this' keyword.
Hope 'that' helped clear some aspects of 'this' :P
Comments
Post a Comment