title: Node.js / JavaScript - JavaScript window variable breaking functionality
body: <p>So on my Jade template, I am passing it a variable through the route which contains an array of names.</p>
  
  <p>Here is the JavaScript from that template:</p>
  
  <pre><code>script(type='text/javascript')
    window.teams = !{JSON.stringify(teams)};
  </code></pre>
  
  <p><code>teams</code> contains the array I spoke about. Here is the JavaScript:</p>
  
  <pre><code>$(function () {
    // Array of team names
    var teamNames = [];
    for(var i = 0; i &lt; teams.length; i++) {
      teamNames.push(teams[i].name);
    }
  
    var bracketTeams = [];
  
    var teamMatches = new Array();
    for(var i=0;i&lt;teamNames.length; i+=2)
    {       
      teamMatches.push([teamNames[i],teamNames[i+1]]);
    }
  
    var bracketData = {
      teams : teamMatches,
      results : [[
          [ [1, 0], [1, 0] ],
          [ [1, 0], [1, 0] ]
        ]]
    }
      $('#tournamentBrackets').bracket({
          init: bracketData
      });
  });
  </code></pre>
  
  <p>Now for some reason, the functionality of the rest of the system completely breaks when I add in this JavaScript code. If I comment it out, then the rest of the system works fine, if I leave it in, buttons do nothing, links go nowhere, data isn't added (although the data is loaded, i.e a database of teams is listed). If I load the page, then uncomment the JS, the page works as it should though.</p>
  
  <p>Any ideas what is breaking my system in this code? I just tried renaming window.teams to window.testName and it still broke. Really confused.</p>
  
  <p>EDIT: HTML generated</p>
  
  <p><a href="http://pastebin.com/VdkEfANb" rel="nofollow">http://pastebin.com/VdkEfANb</a></p>