The Approach I usually take is to assign the C# value to a hidden input field in which you can obtain the value data from javascript. In ASP.NET (Which it appears you are using, correct me if I am wrong) you can do something like
<asp:HiddenField runat="server" id="hdnCsVariable" />
And then in the backend .cs file on page load
hdnCsVariable.Value = "My C# Value";
And finally in the JS since ASP.NET will (usually) generate some hideous id, you can use the "ends with" selector to get your hidden input like so
console.log(document.querySelector("input[id$='hdnCsVariable']").value); // logs "My C# Value"
var javacriptVariable = "<%=this.CsVariable%>"; console.log(javacriptVariable)