Running play framework version 2.3, though it may not be relevant:
I have an html file with the following contents:
<html>
    <head>
        <script type="text/javascript"> if (typeof x === 'undefined') {console.log("x not defined");} else {console.log("in html, x is %s", typeof x);} </script>
        <script type="text/javascript" src="javascripts/somescript.js"></script>
    </head>
</html>
and somescript.js has this:
(function() {
    jQuery(function() {
        if (typeof x === 'undefined') {
            console.log("in somescript.js, x is %s", typeof x);
            var x = something;
            //other stuff
        }
    });
}).call(this);
When I load page first time, x is undefined as expected. However, when I go to a different page within same application, and then come back, the console reads:
in html, x is object
in somescript.js, x is undefined
This is weird because in html, if statement is false, but in somescript.js, same if statement is true.
Why is it doing this, and how can I make sure both scripts run in same way?
 
    