javascript: null variable in function changes its value? <p>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.</p> <pre><code>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(); </code></pre> <p>Output: f is null (only once) g</p>