 <p>You could use the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors" rel="nofollow noreferrer">property accessor</a>, like the assignment.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var f = function() { console.log("Hello! " + f.x); } f.x = "Whoohoo"; console.log(f.x); f();</code></pre> </div> </div> </p> <p>For stable access, you could use a named function </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var f = function foo() { console.log("Hello! " + foo.x); } // ^^^ &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; ^^^ f.x = "Whoohoo"; console.log(f.x); f();</code></pre> </div> </div> </p>