Why can I reference a variable not yet defined in Javascript?
<p>When creating the function <code>foo</code> here, I reference a variable <code>fromTheFuture</code> the hasn't been declared yet. This <strong>actually works</strong> as expected, but <strong>why</strong>? Is it considered dangerous or bad practice?</p>

<pre><code>var foo = function(x) {
  return fromTheFuture * x;
};

var fromTheFuture = 5;

console.log(foo(10));
</code></pre>

<p>I can see this being very convenient though, if you have several functions that wants use each other in a cycle fashion - without having to declare them all with <code>var</code> in the beginning of the method.</p>
