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