I often run into the problem of producing a javascript array on an ASP.net page from an IEnumerable and I was wondering if there was an easier or clearer way to do it than
<% bool firstItem = true;
foreach(var item in items){
if(firstItem)
{
firstItem = false;
}
else
{%>
,
<%}%>
'<%:item%>'
%>
The whole thing is made much more verbose because of IE's inability to handle a hanging comma in an array or object.