Very strange behavior that I could not understand where the razor variable completely disappears as seen in the screenshot (@SomeID disappears). My goal is to get the id from the server, then assign it to a javascript variable. The problem appears to happen when the razor variable is null and also no matter where I assign this variable even with document ready.
The View:
@{
long? SomeID= (long?)ViewBag.BoxID;
}
<script type="text/javascript">
var testVariable;
function OnElementLoaded() {
testVariable = @SomeID;
}
</script>

foo = "Miles O'brien";, and then dump that into js:testVar = Miles O'Brien;. now you've got an undefined variable (Miles) and a flat-out syntax error with an unexpected extra undefined variable (O) followed by an unterminated string'Brien