Variables scope <p>I have two javascript files included at the header of my website. Both files contains almost same variables. </p> <p>If I have header like this </p> <pre><code> &lt;head&gt; &lt;script src="http://127.0.0.1/js/file1.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://127.0.0.1/js/file2.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; </code></pre> <p>Is it possible to access vars defined in file1.js from file2.js ?</p> <p>This is what i`m trying</p> <pre><code> file1 $(function() { var x = 1; }); file2 $(function() { console.log(x); //This dosen`t work. Can`t access var }); </code></pre>