What you are trying to do is not possible. Something that is important to understand between code in Razor and javascript , that the first is processed on the server side and the other is executed on the client (ie the browser).
When you make a request for a certain page, that page is processed on the server and after it is received by the browser, the code is processed on the client side (javscript, css, html, etc.).
Therefore, as you can conclude it is not possible to do what you mention. What you could achieve is the inverse behavior, process something on the server and write in a javascript code. Something like the following
<script type="text/javascript">
var variable_from_server= '@Model.Variable_From_Server';
</script>
I hope it was clear and useful.
Greetings