{% embed url="https://dev.to/naveenkolambage/test-11fd" %}
Here's an object which uses this keyword
const man = {
name: "rick",
adventure() {
console.log(this);
}
};
man.adventure(); Executing above you will see the man object on the console.
But what if you do;
const adventure_reference = man.adventure;
adventure_reference();Output then would be;
Value of 'this' is determined by how a function is called;
- If we call a function as a method in an object this will always return a reference to that object.
- If we call a function as a standalone object - or outside an object this will return the global object which is the window object in browsers.

