How to convert scala list to javascript array?
Is there a simpler way of doing this? $(document).ready(function () { var jsArray = [] @if(scalaList != null) { @for(id <- scalaList) { jsArray.push('@id'); } } ... } It's as simple as the following: import play.api.libs.json.Json val jsArr: JsValue = Json.toJson(scalaList) You can also do that within a template: @(list: List[Any]) @import play.api.libs.json.Json <script type="text/javascript"> $(document).ready(function () { var jsArr = @Json.toJson(list); console.log(jsArr); }); </script> You can use mkString for this. $(document).ready(function () { var jsArray = @if(scalaList != null) { [