You need to translate it into JSON on a server-side.
<script>
var ServiceNotes = @(Html.Raw(JsonConvert.SerializeObject(ViewBag.ServiceNotes)));
var ServiceName = @(Html.Raw(JsonConvert.SerializeObject(ViewBag.ServiceName)));
var ServiceIndex = @(Html.Raw(JsonConvert.SerializeObject(ViewBag.ServiceIndex)));
</script>
Then access it directly in JS.
The empty array is correctly processed by JsonConvert, so, if it is empty you will get something like
var ServiceNotes = [];
For the convenience of debugging and avoiding nested function calls you can also split serializing and output.
@{
string serviceNotesJson = JsonConvert.SerializeObject(ViewBag.ServiceNotes);
string serviceNameJson = JsonConvert.SerializeObject(ViewBag.ServiceName);
string serviceIndexJson = JsonConvert.SerializeObject(ViewBag.ServiceIndex);
}
@section scripts
{
<script>
var ServiceNotes = @(Html.Raw(serviceNotesJson));
var ServiceName = @(Html.Raw(serviceNameJson));
var ServiceIndex = @(Html.Raw(serviceIndexJson));
</script>
}