title: How to pass model object to a javascript function
body: <p>In my razor view (cshtml), I want to pass my model object to a javascript function as a whole and have the javascript function perform some operations on it, but I'm having an issue trying to pass the model.  Here is what I have:</p>
  
  <pre><code>@model TestModel
  
  &lt;body&gt;
  ...
  ...
  &lt;a onclick="DoSomething(@Model)"&gt;TestClickLink&lt;/a&gt;
  ...
  ...
  &lt;/body&gt;
  
  &lt;script&gt;
  
      function DoSomething(theModel) {
          theModel.variable1 = something
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>How can I pass my current model with all it's values to the javascript function? I'm not very versed in javascript so please be detailed with your explanations if you can, any help would be appreciate it</p>