I am learning javascript but I have some doubts about functions/closures, i have this code:
var obj = { value: 0 };
obj.test = function() {
    var that = this;
    var f1 = function() {
        console.log(that);
    };
    f1();
};
obj.test();
var x = obj.test;
x();
I know that when a function is invoked like  f()  this refer to the global object but in my example when f1 is defined it has a reference that to the this of the outer function that refer to obj. 
I expect that the function remember the context in which it was created so why the last call x() refers to the global object?
Thanks
 
     
     
    