It depends
This is a
jsp example:
<%
String[] values = myClass.getValuesFromDB();
%>
<script>
var jsArray = new Array();
<% for(int i=0;values!=null && i<values.length;i++){%>
//this line assumes you can not get '\n' or double quotes from db
//if so you have to escape them.
jsArray[<%=i%>]= "<%=values[i]%>";
<%}%>
</script>