Can a null variable in a function become not null? When f enters in function chainF it somehow changes its value? It isn't null anymore.
function TestF(){}
TestF.prototype = {
i: 0,
f: null,
chainF: function(g){
if(this.f == null)
console.log('f is null');
var newF = function(){
if(this.f == null)
console.log('f is null');
g();
};
this.f = newF;
return this;
}
}
t = new TestF();
t.chainF(function(){console.log('g')}).f();
Output: f is null (only once) g