In a regular object, this inside a method is pointing to the object itself; in a function call, this is pointing to the caller, sometimes, the Window object if it is called globally. I have no problem with those. What I don't understand is the code snippet below:
function test(){
function method(){console.log(this);}
method();
}
test()
Since JavaScript function is also an object, I would expect this inside method function should point to the caller which is test object. However, it is pointed to Window object. Why is that? Can someone help me get a consistent understanding about this magic word this? Thank you!