title: Razor Syntax in External Javascript
body: <p>So as you might know, Razor Syntax in ASP.NET MVC does not work in external JavaScript files. </p>
  
  <p>My current solution is to put the Razor Syntax in a  a global variable and set the value of that variable from the mvc view that is making use of that .js file.</p>
  
  <p><strong>JavaScript file:</strong></p>
  
  <pre><code>function myFunc() {
    alert(myValue);
  }
  </code></pre>
  
  <p><strong>MVC View file:</strong></p>
  
  <pre><code>&lt;script language="text/javascript"&gt;
      myValue = @myValueFromModel;
  &lt;/script&gt;
  </code></pre>
  
  <p>I want to know how I can  pass myValue <strong><em>directly as a parameter</em></strong> to the function ? I prefer to have explicit calling with param than relying on globals, however I'm not so keen on javascript.</p>
  
  <p>How would I implement this with javascript parameters? Thanks!</p>