I was wondering if it is possible to access foo from window.updateFoo() in the code below:
function f1 () {
'use strict';
this.x = {};
this.x.foo = 0;
window.updateFoo = function(val){
this.x.foo = val; // Obviously wrong since 'this' doesn't refer to f1 now. Uncaught TypeError: Cannot set property 'foo' of undefined
};
window.updateFoo(20); // Try changing the value of this.x.foo?
}