I am trying to write a code in javascript
var x=20;
var a={
  x:10,
  fun:(function(){
        console.log(this);
        function q(){
              console.log(this);
        }
        q();
  })
}
a.fun();
It gives me
Object {x: 10, fun: function}
Window {stop: function, open: function, alert: function, confirm: function, prompt: function…}.
But I don't understand why last "this" point to the window object. Please help me out how "this" keyword is actually working.
 
    