You can also do like this, which is the most compact I guess:
In your @Controller
:
model.addAttribute("items", new String[] { "item1", "item2", "item3" });
In your template:
<script type="text/javascript" th:inline="javascript">
var items = [];
/*[# th:each="n : ${items}"]*/
items.push("[(${n})]");
/*[/]*/
</script>
Other useful stuff is explained here: [MAJOR FEAT] New syntax for textual template modes #395