Skip to main content

This vs. That

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

Comments

Popular posts from this blog

Stack vs. Queue

Stack is like a pile of  books placed on top of each other. We can add new books to the top and can remove them from only the top because stacks are LIFO which means last-in, first-out. Queues on the other hand are the opposite, which is FIFO meaning first-in, first-out. So adding an element to the queue will be the same but removing will happen to the first element not the last one. An example of a queue would be the wait line in front of any kind of service we see around us like the bus station or the shops,....etc.

Middlewares

Middlewares in Javascript are functions that come in the middle of the request-response cycle. They have access to both the request and the response object as well as the next middleware function to be executed; usually called next(). Popular examples on middleware include: body-parser, cors, session, cookie-seesion and cookie-parser.