title: How to use a global variable that is visible by both HTML/Razor and javascript all on the same page
body: <p>Here is my layout</p>
  
  <pre><code>&lt;html&gt;
  @{ bool isAdmin = true; }
  
  if(isAdmin)
  {
  //the breakpoint hits here
  }
  &lt;/html&gt;
  
  &lt;script type="text/javascript"&gt;
  function someFunction()
  {
  if(isAdmin){ //my breakpoint doesnt hit here}
  }
  $(document).ready(function()
  {
   @if(isAdmin){ //my breakpoint hits here}
  somefunction();
  }   
  &lt;/script&gt;
  </code></pre>
  
  <p>How is it that my global variable is visible from the html/razor within the html and also within the javascript, yet it cannot be seen from the function within the javascript. This doesnt make sense to me. Also if i try something like adding @isAdmin to the function parameter, the error i get is "True is undefined", if i .ToLower() "True", the error is "unexpected token true" </p>